com.electrotank.electroserver.plugins
Class AbstractPlugin

java.lang.Object
  extended byBaseExtension
      extended bycom.electrotank.electroserver.plugins.AbstractPlugin

public abstract class AbstractPlugin
extends BaseExtension

The AbstractPlugin represents an abstract class that must be extended for all Java plugins. It contains a series of methods that can be over ridden to provide various functionality needed to create your own extentions to the server. See the articles at http://www.electrotank.com/electroserver for more details.

See Also:
Serialized Form

Field Summary
static String EXECUTING_USER_NAME
          The name of the client that has made this request.
static String MESSAGE_TEXT
          The exact textual data sent from the client.
static String METHOD
          The name of the method that the client wishes to execute.
 
Constructor Summary
AbstractPlugin()
           
 
Method Summary
 PluginHelper getPluginHelper()
          Allows a plugin to get an instance of its PluginHelper.
abstract  void pluginDestroy()
          Called when the plugin is to be unloaded.
abstract  void pluginInit(Map parameters)
          Called when the plugin is first initialized.
 Map pluginInterop(Map parameters)
          Called by another plugin using the PluginHelper method "callRemotePlugin".
abstract  void pluginRequest(Map parameters)
          Called when a client requests something from the server.
 void pluginUserEnter(String userName, int userNumber)
          Allows for a plugin to be notified when a user enters this room.
 void pluginUserExit(String userName, int userNumber)
          Allows for a plugin to be notified when a user leaves this room.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

METHOD

public static final String METHOD
The name of the method that the client wishes to execute. Represents an entry in the Map object passed into the pluginRequest method.

See Also:
Constant Field Values

EXECUTING_USER_NAME

public static final String EXECUTING_USER_NAME
The name of the client that has made this request. Represents an entry in the Map object passed into the pluginRequest method.

See Also:
Constant Field Values

MESSAGE_TEXT

public static final String MESSAGE_TEXT
The exact textual data sent from the client. Represents an entry in the Map object passed into the pluginRequest method. This is only populated if the plugin is being used as a "raw" plugin.

See Also:
Constant Field Values
Constructor Detail

AbstractPlugin

public AbstractPlugin()
Method Detail

pluginInit

public abstract void pluginInit(Map parameters)
                         throws PluginException
Called when the plugin is first initialized. For a server-level plugin, this is called when the server is starting up and before it can accept connections from clients. For a room-level plugin, this is called when the room is created.

Parameters:
parameters - contains the name/value pairs of variables passed into the method.
Throws:
PluginException - thrown when an exception occurs at the plugin level and it needs to be handled by the server.

pluginRequest

public abstract void pluginRequest(Map parameters)
                            throws PluginException
Called when a client requests something from the server.

Parameters:
parameters - contains the name/value pairs of variables passed into the method.
Throws:
PluginException - thrown when an exception occurs at the plugin level and it needs to be handled by the server.

pluginDestroy

public abstract void pluginDestroy()
                            throws PluginException
Called when the plugin is to be unloaded. For a server-level plugin, this is never called. For a room-level plugin, this is called when the room is destroyed. It is essential that plugins clean up external resources like threads and socket/file IO when the plugin is destroyed to avoid resource leaks that can ultimatly destabilize the server.

Throws:
PluginException - thrown when an exception occurs at the plugin level and it needs to be handled by the server.

pluginInterop

public Map pluginInterop(Map parameters)
                  throws PluginException
Called by another plugin using the PluginHelper method "callRemotePlugin". This method allows plugins to communicate back and forth. Plugins can only communicate from room-level to server-level and server-level to server-level. A room-level plugin is NOT able to call another room-level plugin via this mechanism. You could use one of the many supported techniques in Java to facilirate that ie. JMS, sockets, RMI, etc.

Parameters:
parameters - Map containing the name/value pairs of data to be used
Returns:
Map containing the name/value pairs response
Throws:
PluginException - thrown when an exception occurs at the plugin level and it needs to be handled by the server.

pluginUserEnter

public void pluginUserEnter(String userName,
                            int userNumber)
                     throws PluginException
Allows for a plugin to be notified when a user enters this room. Is only called for room-level plugins.

Parameters:
userNumber - number of the user who just entered.
userName - name of the user that just entered
Throws:
PluginException - thrown when an exception occurs at the plugin level and it needs to be handled by the server.

pluginUserExit

public void pluginUserExit(String userName,
                           int userNumber)
                    throws PluginException
Allows for a plugin to be notified when a user leaves this room. Is only called for room-level plugins.

Parameters:
userNumber - number of the user who just left.
userName - name of the user that just left
Throws:
PluginException - thrown when an exception occurs at the plugin level and it needs to be handled by the server.

getPluginHelper

public final PluginHelper getPluginHelper()
Allows a plugin to get an instance of its PluginHelper.

Returns:
instance of PluginHelper associated with this plugin


Copyright © 2006 Electrotank, Inc. All Rights Reserved.