public abstract class BaseSFSExtension extends java.lang.Object implements ISFSExtension, ISFSEventListener
SFSExtension| Modifier and Type | Field and Description |
|---|---|
protected int |
lagOscillation |
protected int |
lagSimulationMillis
Experimental lag simulator.
|
protected org.slf4j.Logger |
logger |
protected ISFSApi |
sfsApi
A reference to the SFS2X API
|
| Constructor and Description |
|---|
BaseSFSExtension() |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventListener(SFSEventType eventType,
ISFSEventListener listener)
Allows to add a listener for a specific server event.
|
ISFSApi |
getApi()
Get a reference to the main SFS2X Server API, which exposes useful methods for interacting with the server
|
ISFSBuddyApi |
getBuddyApi()
Get a reference to the SFS2X Buddy API, exposing useful methods for working with BuddyLists
|
java.util.Properties |
getConfigProperties()
Returns a reference the Properties object loaded from the specified properties file.
|
java.lang.String |
getCurrentFolder()
Return the relative path to the current extension folder
Typically this will return: extensions/{name-of-extension}/ The path is relative to the Server root folder and it can be used to load external data files that are stored together with the extension jar file(s) |
java.lang.String |
getExtensionFileName()
Get the extension file name
|
ISFSGameApi |
getGameApi()
Get a reference to the SFS2X Game API, exposing useful methods for working with SFSGame classes, invitations and match making.
|
com.smartfoxserver.v2.extensions.ExtensionLevel |
getLevel()
Return the level of the extension.
|
org.slf4j.Logger |
getLogger()
Obtain a direct reference to the Extension's logger
|
ISFSMMOApi |
getMMOApi()
Get a reference to the SFS2X MMO API, exposing useful methods for working with MMORoom(s) and MMOItem(s) objects.
|
java.lang.String |
getName()
The extension name
|
Room |
getParentRoom()
Return the parent Room of the Extension.
|
Zone |
getParentZone()
Return the parent Zone of the Extension.
|
java.lang.String |
getPropertiesFileName()
Get the name of the properties file that was loaded at init time.
|
ExtensionReloadMode |
getReloadMode() |
com.smartfoxserver.v2.extensions.ExtensionType |
getType() |
java.lang.Object |
handleInternalMessage(java.lang.String cmdName,
java.lang.Object params)
This method can be invoked across different Extensions.
|
void |
handleServerEvent(ISFSEvent event)
Handle server event
|
boolean |
isActive()
Checks if the Extension is active.
|
void |
removeEventListener(SFSEventType eventType,
ISFSEventListener listener)
Remove an event listener
|
protected void |
removeEventsForListener(ISFSEventListener listener) |
void |
send(java.lang.String cmdName,
ISFSObject params,
java.util.List<User> recipients) |
void |
send(java.lang.String cmdName,
ISFSObject params,
java.util.List<User> recipients,
boolean useUDP)
Send an extension message/response to a list of recipients
|
void |
send(java.lang.String cmdName,
ISFSObject params,
User recipient) |
void |
send(java.lang.String cmdName,
ISFSObject params,
User recipient,
boolean useUDP)
Send an extension message/response to a single User
|
void |
setActive(boolean flag) |
void |
setExtensionFileName(java.lang.String fileName) |
void |
setLevel(com.smartfoxserver.v2.extensions.ExtensionLevel level) |
void |
setName(java.lang.String name) |
void |
setParentRoom(Room room) |
void |
setParentZone(Zone zone) |
void |
setPropertiesFileName(java.lang.String fileName) |
void |
setReloadMode(ExtensionReloadMode mode) |
void |
setType(com.smartfoxserver.v2.extensions.ExtensionType type) |
java.lang.String |
toString() |
void |
trace(ExtensionLogLevel level,
java.lang.Object... args)
Trace a message to the console and log files using the specified logging level
|
void |
trace(java.lang.Object... args)
Traces a message to the console and log files using the Logger INFO level
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdestroy, handleClientRequest, initprotected volatile int lagSimulationMillis
Set this value to any int > 0 and it will cause the current thread to delay any response by the amount of milliseconds specified.
Default setting is == 0, no lag!
protected volatile int lagOscillation
protected final org.slf4j.Logger logger
public java.lang.String getCurrentFolder()
public java.lang.String getName()
getName in interface ISFSExtensionpublic void setName(java.lang.String name)
setName in interface ISFSExtensionpublic java.lang.String getExtensionFileName()
getExtensionFileName in interface ISFSExtensionpublic java.util.Properties getConfigProperties()
By default SmartFox will attempt to load a file called config.properties located in the Extension folder. Example: if your extension name is ChessGame the system will try to load extensions/ChessGame/config.properties
No errors will be logged if the file is not found unless you have specified a custom properties file. In this case a warning will be logged if the file cannot be loaded.
If the file is not found the method will return null
getConfigProperties in interface ISFSExtensionpublic java.lang.String getPropertiesFileName()
getPropertiesFileName in interface ISFSExtensionpublic void setPropertiesFileName(java.lang.String fileName)
throws java.io.IOException
setPropertiesFileName in interface ISFSExtensionjava.io.IOExceptionpublic ISFSApi getApi()
ISFSApipublic ISFSBuddyApi getBuddyApi()
ISFSBuddyApipublic ISFSGameApi getGameApi()
ISFSGameApipublic ISFSMMOApi getMMOApi()
ISFSMMOApipublic void handleServerEvent(ISFSEvent event) throws java.lang.Exception
handleServerEvent in interface ISFSEventListenerevent - the Eventjava.lang.ExceptionSFSEventpublic java.lang.Object handleInternalMessage(java.lang.String cmdName,
java.lang.Object params)
handleInternalMessage in interface ISFSExtensioncmdName - a command nameparams - custom parameterspublic void setExtensionFileName(java.lang.String fileName)
setExtensionFileName in interface ISFSExtensionpublic Room getParentRoom()
getParentRoom in interface ISFSExtensionpublic void setParentRoom(Room room)
setParentRoom in interface ISFSExtensionpublic Zone getParentZone()
getParentZone in interface ISFSExtensionpublic void setParentZone(Zone zone)
setParentZone in interface ISFSExtensionpublic void addEventListener(SFSEventType eventType, ISFSEventListener listener)
addEventListener in interface ISFSExtensioneventType - the type of event to listen forlistener - the event handlerSFSEventType,
ISFSEventListenerpublic void removeEventListener(SFSEventType eventType, ISFSEventListener listener)
removeEventListener in interface ISFSExtensioneventType - the type of eventlistener - the event handlerSFSEventType,
ISFSEventListenerpublic boolean isActive()
isActive in interface ISFSExtensionpublic void setActive(boolean flag)
setActive in interface ISFSExtensionpublic com.smartfoxserver.v2.extensions.ExtensionLevel getLevel()
getLevel in interface ISFSExtensionpublic void setLevel(com.smartfoxserver.v2.extensions.ExtensionLevel level)
setLevel in interface ISFSExtensionpublic com.smartfoxserver.v2.extensions.ExtensionType getType()
getType in interface ISFSExtensionpublic void setType(com.smartfoxserver.v2.extensions.ExtensionType type)
setType in interface ISFSExtensionpublic ExtensionReloadMode getReloadMode()
getReloadMode in interface ISFSExtensionpublic void setReloadMode(ExtensionReloadMode mode)
setReloadMode in interface ISFSExtensionpublic void send(java.lang.String cmdName,
ISFSObject params,
java.util.List<User> recipients)
send in interface ISFSExtensionpublic void send(java.lang.String cmdName,
ISFSObject params,
User recipient)
send in interface ISFSExtensionpublic void send(java.lang.String cmdName,
ISFSObject params,
java.util.List<User> recipients,
boolean useUDP)
send in interface ISFSExtensioncmdName - the command nameparams - custom parametersrecipients - the list of recipientsuseUDP - send as UDP packetpublic void send(java.lang.String cmdName,
ISFSObject params,
User recipient,
boolean useUDP)
ISFSExtensionsend in interface ISFSExtensioncmdName - the command nameparams - custom parametersrecipient - the recipient of the messageuseUDP - send as UDP packetpublic java.lang.String toString()
toString in class java.lang.Objectpublic org.slf4j.Logger getLogger()
public void trace(java.lang.Object... args)
args - any number of strings/object to tracepublic void trace(ExtensionLogLevel level, java.lang.Object... args)
level - the logging levelargs - any number of object to traceprotected void removeEventsForListener(ISFSEventListener listener)