com.mooapi.server.handler
Interface MooServerHandler

All Known Implementing Classes:
MooServerAdapter

public interface MooServerHandler

Implement this interface to provide command filtering, server-side gameplay or for any reason you see fit. The input and output command classes contain setters for each property so that any imaginable type of filtering can be performed on incoming and outgoing MooAPI commands.

Author:
Steve Taylor

Method Summary
 void afterConnected(MooConnection source)
          This is called once a connection has been established and promoted to a MooAPI connection.
 void afterOutput(MooConnection destination, AbstractServerCommand command)
          This is called after an output command has been sent.
 boolean beforeConnected(java.lang.String ipAddress)
          This is called after a TCP/IP connection is established, but before it has been promoted to a MooAPI connection.
 void beforeInput(MooConnection connection, AbstractClientCommand command, CommandProcessor processor)
          This is called before an input command is processed.
 void onChannelCreated(MooConnection source, MooChannel channel)
          This is called when a channel has been created.
 void onChannelDestroyed(MooChannel channel)
          This is called when a channel has been destroyed.
 void onChannelJoined(MooConnection source, MooChannel channel)
          This is called when a connection has joined a channel.
 void onChannelLeft(MooConnection source, MooChannel channel)
          This is called when a connection has left a channel.
 void onChannelLimitReached()
          This is called when the channel limit has been reached.
 void onConnectionLimitReached()
          This is called when the connection limit has been reached.
 void onDisconnected(MooConnection source)
          This is called when a connection has disconnected from the server.
 void onError(MooConnection source, java.lang.Throwable cause)
          This is called when an error is thrown.
 

Method Detail

beforeInput

void beforeInput(MooConnection connection,
                 AbstractClientCommand command,
                 CommandProcessor processor)
This is called before an input command is processed. Implementing classes may modify the command before it is processed and/or prevent it from being processed. If the command is to be processed, it should be passed to the specified processor.

Parameters:
connection - The source connection.
command - The input command.
processor - The input command processor.

afterOutput

void afterOutput(MooConnection destination,
                 AbstractServerCommand command)
This is called after an output command has been sent.

Parameters:
destination - The connection to which the output command was sent.
outputCommand - The output command.

beforeConnected

boolean beforeConnected(java.lang.String ipAddress)
This is called after a TCP/IP connection is established, but before it has been promoted to a MooAPI connection. Implementing classes can determine whether to promote the connection or drop it by returning true or false respectively. It is recommended to implement IP-based filtering at the firewall level as it is more efficient and better at preventing DOS attacks.

Parameters:
ipAddress - The connection's IP address.
Returns:
true to allow the connection, otherwise false.

afterConnected

void afterConnected(MooConnection source)
This is called once a connection has been established and promoted to a MooAPI connection.

Parameters:
source - The connection.

onChannelCreated

void onChannelCreated(MooConnection source,
                      MooChannel channel)
This is called when a channel has been created.

Parameters:
source - The connection that created the channel.
channel - The new channel.

onChannelJoined

void onChannelJoined(MooConnection source,
                     MooChannel channel)
This is called when a connection has joined a channel.

Parameters:
source - The connection.
channel - The channel.

onChannelLeft

void onChannelLeft(MooConnection source,
                   MooChannel channel)
This is called when a connection has left a channel.

Parameters:
source - The connection.
channel - The channel.

onError

void onError(MooConnection source,
             java.lang.Throwable cause)
This is called when an error is thrown.

Parameters:
source - The associated connection.
cause - The error.

onDisconnected

void onDisconnected(MooConnection source)
This is called when a connection has disconnected from the server.

Parameters:
source - The connection.

onChannelDestroyed

void onChannelDestroyed(MooChannel channel)
This is called when a channel has been destroyed.

Parameters:
channel - The channel.

onConnectionLimitReached

void onConnectionLimitReached()
This is called when the connection limit has been reached.


onChannelLimitReached

void onChannelLimitReached()
This is called when the channel limit has been reached.



Copyright © 2009. All Rights Reserved.