com.mooapi.server.handler
Class MooServerAdapter

java.lang.Object
  extended by com.mooapi.server.handler.MooServerAdapter
All Implemented Interfaces:
MooServerHandler

public class MooServerAdapter
extends java.lang.Object
implements MooServerHandler

This is a default implementation of MooConnectionHandler. Use this to provide an implementation that allows all requests without modifying them, or as a superclass to a custom handler that isn't concerned with customising every aspect of the server. Alternatively, fully implement MooConnectionHandler in a class when full customisation is required. See MooConnectionHandler for full method documentation.


Constructor Summary
MooServerAdapter()
           
 
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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MooServerAdapter

public MooServerAdapter()
Method Detail

beforeInput

public void beforeInput(MooConnection connection,
                        AbstractClientCommand command,
                        CommandProcessor processor)
Description copied from interface: MooServerHandler
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.

Specified by:
beforeInput in interface MooServerHandler
Parameters:
connection - The source connection.
command - The input command.
processor - The input command processor.

afterOutput

public void afterOutput(MooConnection destination,
                        AbstractServerCommand command)
Description copied from interface: MooServerHandler
This is called after an output command has been sent.

Specified by:
afterOutput in interface MooServerHandler
Parameters:
destination - The connection to which the output command was sent.

beforeConnected

public boolean beforeConnected(java.lang.String ipAddress)
Description copied from interface: MooServerHandler
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.

Specified by:
beforeConnected in interface MooServerHandler
Parameters:
ipAddress - The connection's IP address.
Returns:
true to allow the connection, otherwise false.

afterConnected

public void afterConnected(MooConnection source)
Description copied from interface: MooServerHandler
This is called once a connection has been established and promoted to a MooAPI connection.

Specified by:
afterConnected in interface MooServerHandler
Parameters:
source - The connection.

onChannelCreated

public void onChannelCreated(MooConnection source,
                             MooChannel channel)
Description copied from interface: MooServerHandler
This is called when a channel has been created.

Specified by:
onChannelCreated in interface MooServerHandler
Parameters:
source - The connection that created the channel.
channel - The new channel.

onChannelJoined

public void onChannelJoined(MooConnection source,
                            MooChannel channel)
Description copied from interface: MooServerHandler
This is called when a connection has joined a channel.

Specified by:
onChannelJoined in interface MooServerHandler
Parameters:
source - The connection.
channel - The channel.

onChannelLeft

public void onChannelLeft(MooConnection source,
                          MooChannel channel)
Description copied from interface: MooServerHandler
This is called when a connection has left a channel.

Specified by:
onChannelLeft in interface MooServerHandler
Parameters:
source - The connection.
channel - The channel.

onError

public void onError(MooConnection source,
                    java.lang.Throwable cause)
Description copied from interface: MooServerHandler
This is called when an error is thrown.

Specified by:
onError in interface MooServerHandler
Parameters:
source - The associated connection.
cause - The error.

onDisconnected

public void onDisconnected(MooConnection source)
Description copied from interface: MooServerHandler
This is called when a connection has disconnected from the server.

Specified by:
onDisconnected in interface MooServerHandler
Parameters:
source - The connection.

onChannelDestroyed

public void onChannelDestroyed(MooChannel channel)
Description copied from interface: MooServerHandler
This is called when a channel has been destroyed.

Specified by:
onChannelDestroyed in interface MooServerHandler
Parameters:
channel - The channel.

onConnectionLimitReached

public void onConnectionLimitReached()
Description copied from interface: MooServerHandler
This is called when the connection limit has been reached.

Specified by:
onConnectionLimitReached in interface MooServerHandler

onChannelLimitReached

public void onChannelLimitReached()
Description copied from interface: MooServerHandler
This is called when the channel limit has been reached.

Specified by:
onChannelLimitReached in interface MooServerHandler


Copyright © 2009. All Rights Reserved.