it.gotoandplay.smartfoxserver.extensions
Class AbstractExtension

java.lang.Object
  extended by it.gotoandplay.smartfoxserver.extensions.AbstractExtension
All Implemented Interfaces:
it.gotoandplay.smartfoxserver.events.IEventListener, it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension
Direct Known Subclasses:
PixelGame, SimpleDbExtension, SimpleExtension

public abstract class AbstractExtension
extends java.lang.Object
implements it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension, it.gotoandplay.smartfoxserver.events.IEventListener

AbstractExtension is the parent class for all SmartFoxServer extensions


Field Summary
 it.gotoandplay.smartfoxserver.extensions.AdminExtension adminExtension
           
 
Constructor Summary
AbstractExtension()
           
 
Method Summary
 void destroy()
           
 java.lang.String getOwnerRoom()
          Get the name of the room where the extension is attached to (if any)
 java.lang.String getOwnerZone()
          Get the name of the zone where the extension is attached to
 void handleRequest(java.lang.String cmd, org.json.JSONObject jso, User u, int fromRoom)
          Basic implementation of interface method Needed to avoid breaking extensions of version 1.4.0 and previous which only handle XML or String requests
 void init()
           
 boolean isActive()
          Returns true if the extension is active
 net.n3.nanoxml.IXMLElement loadConfig(java.lang.String xmlFile)
           
 void registerForEvents(java.lang.String zoneName, java.lang.String roomName)
           
 void sendResponse(ActionscriptObject ao, int fromRoom, User sender, java.util.LinkedList recipients)
          Send a response to one or more clients using XML format
 void sendResponse(org.json.JSONObject jso, int fromRoom, User sender, java.util.LinkedList recipients)
          Send a response to one or more clients using JSON format
 void sendResponse(java.lang.String[] params, int fromRoom, User sender, java.util.LinkedList recipients)
          Send a response to one or more clients using String format
 void setActive(boolean b)
           
 void setOwner(java.lang.String zoneName, java.lang.String roomName)
           
 void trace(java.lang.String msg)
          Trace the message remotely to admin tool and to the console
 void unRegister()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension
handleRequest, handleRequest
 
Methods inherited from interface it.gotoandplay.smartfoxserver.events.IEventListener
handleInternalEvent
 

Field Detail

adminExtension

public it.gotoandplay.smartfoxserver.extensions.AdminExtension adminExtension
Constructor Detail

AbstractExtension

public AbstractExtension()
Method Detail

setOwner

public void setOwner(java.lang.String zoneName,
                     java.lang.String roomName)
Specified by:
setOwner in interface it.gotoandplay.smartfoxserver.events.IEventListener

getOwnerZone

public java.lang.String getOwnerZone()
Get the name of the zone where the extension is attached to

Specified by:
getOwnerZone in interface it.gotoandplay.smartfoxserver.events.IEventListener
Returns:
the zone name of the extension

getOwnerRoom

public java.lang.String getOwnerRoom()
Get the name of the room where the extension is attached to (if any)

Specified by:
getOwnerRoom in interface it.gotoandplay.smartfoxserver.events.IEventListener
Returns:
the room name of the extension (can be null, if extension is at Zone level only)

init

public void init()
Specified by:
init in interface it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension

destroy

public void destroy()
Specified by:
destroy in interface it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension

isActive

public boolean isActive()
Returns true if the extension is active

Specified by:
isActive in interface it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension
Returns:
true if the extension is active

setActive

public void setActive(boolean b)
Specified by:
setActive in interface it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension

registerForEvents

public void registerForEvents(java.lang.String zoneName,
                              java.lang.String roomName)
Specified by:
registerForEvents in interface it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension

unRegister

public void unRegister()
Specified by:
unRegister in interface it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension

trace

public void trace(java.lang.String msg)
Trace the message remotely to admin tool and to the console

Parameters:
msg - the string message to trace

loadConfig

public net.n3.nanoxml.IXMLElement loadConfig(java.lang.String xmlFile)

handleRequest

public void handleRequest(java.lang.String cmd,
                          org.json.JSONObject jso,
                          User u,
                          int fromRoom)
Basic implementation of interface method Needed to avoid breaking extensions of version 1.4.0 and previous which only handle XML or String requests

Specified by:
handleRequest in interface it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension

sendResponse

public void sendResponse(ActionscriptObject ao,
                         int fromRoom,
                         User sender,
                         java.util.LinkedList recipients)
Send a response to one or more clients using XML format

Specified by:
sendResponse in interface it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension
Parameters:
ao - the ActionscriptObject containing the data for the client
fromRoom - the roomId (-1 for none)
recipients - a list of SocketChannels
sender - the User object of the sender (if null, the sender is the Server)

sendResponse

public void sendResponse(java.lang.String[] params,
                         int fromRoom,
                         User sender,
                         java.util.LinkedList recipients)
Send a response to one or more clients using String format

Specified by:
sendResponse in interface it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension
Parameters:
params - an array of String params
fromRoom - the roomId (-1 for none)
recipients - a list of SocketChannels
sender - the User object of the sender (if null, the sender is the Server)

sendResponse

public void sendResponse(org.json.JSONObject jso,
                         int fromRoom,
                         User sender,
                         java.util.LinkedList recipients)
Send a response to one or more clients using JSON format

Specified by:
sendResponse in interface it.gotoandplay.smartfoxserver.extensions.ISmartFoxExtension
Parameters:
jso - a JSONObject
fromRoom - the roomId (-1 for none)
recipients - a list of SocketChannels
sender - the User object of the sender (if null, the sender is the Server)