org.jdesktop.wonderland.server.comms
Interface CommsManager


public interface CommsManager

Manage communications protocols.

Author:
jkaplan

Method Summary
 ClientConnectionHandler getClientHandler(ConnectionType clientType)
          Get a ClientConnectionHandler by the ConnectionType it handles
 java.util.Set<ClientConnectionHandler> getClientHandlers()
          Get all registered client handler
 java.util.Set<com.sun.sgs.app.ClientSession> getClients(CommunicationsProtocol protocol)
          Get all sessions that are connected using the given protocol
 CommunicationsProtocol getProtocol(com.sun.sgs.app.ClientSession session)
          Get the communication protocol used by the given client session
 CommunicationsProtocol getProtocol(java.lang.String name)
          Get a communications protocol by name
 java.util.Set<CommunicationsProtocol> getProtocols()
          Get all communications protocols
 WonderlandClientSender getSender(ConnectionType clientType)
          Get a sender that can be used to send messages to all clients of a given ConnectionType.
 WonderlandClientID getWonderlandClientID(java.math.BigInteger sessionID)
          Get a WonderlandClientID from a sessionID.
 void registerClientHandler(ClientConnectionHandler handler)
          Register a handler that will handle connections from a particular WonderlandClient type.
 void registerProtocol(CommunicationsProtocol protocol)
          Add a new communications protocol.
 void unregisterClientHandler(ClientConnectionHandler handler)
          Unregister a client handler for the given type
 void unregisterProtocol(CommunicationsProtocol protocol)
          Remove a communications protocol from the list of available protocols
 

Method Detail

registerProtocol

void registerProtocol(CommunicationsProtocol protocol)
Add a new communications protocol. When clients connect, they request a communications protocol. The protocol controls how they communicate with the Wonderland server. All communications from that user will be processed by the session listener associated with the given protocol.

Parameters:
protocol - the protocol to register

unregisterProtocol

void unregisterProtocol(CommunicationsProtocol protocol)
Remove a communications protocol from the list of available protocols

Parameters:
protocol - the protocol to remove

getProtocol

CommunicationsProtocol getProtocol(java.lang.String name)
Get a communications protocol by name

Parameters:
name - the name of the protocol to search for
Returns:
the protocol registered with the given name, or null if no protocol exists with that name

getProtocols

java.util.Set<CommunicationsProtocol> getProtocols()
Get all communications protocols

Returns:
all available protocols

getProtocol

CommunicationsProtocol getProtocol(com.sun.sgs.app.ClientSession session)
Get the communication protocol used by the given client session

Parameters:
session - the client session to check
Returns:
the protocol in use by the given client, or null if the given client is not connected

getClients

java.util.Set<com.sun.sgs.app.ClientSession> getClients(CommunicationsProtocol protocol)
Get all sessions that are connected using the given protocol

Parameters:
protocol - the protocol to get session for
Returns:
all sessions connected with the given protocol

registerClientHandler

void registerClientHandler(ClientConnectionHandler handler)
Register a handler that will handle connections from a particular WonderlandClient type. This listener will be notified of all connections and messages from listeners of the given type.

This handler will be notified when a client session, which is connected via the WonderlandProtocol, connects a new WonderlandClient using the WonderlandSession.connect() method. It will be notified of all messages sent using that client type.

The Handler will be stored in the Darkstar data store, so it must be either Serializable or a ManagedObject. If a handler is a ManagedObject, only a single copy of the handler will exist, and all messages will be forwarded to this object. If the handler is not a managed object, a separate copy of the handler will be created in each WonderlandSession that connects a client of the given type. It is recommended that handlers that expect a large number messages be Serializable.

This is identical to calling WonderlandSessionListener.registerClientHandler().

Parameters:
handler - the handler to handle messages from the given client type

unregisterClientHandler

void unregisterClientHandler(ClientConnectionHandler handler)
Unregister a client handler for the given type

Parameters:
handler - the handler to unregister

getClientHandler

ClientConnectionHandler getClientHandler(ConnectionType clientType)
Get a ClientConnectionHandler by the ConnectionType it handles

Parameters:
clientType - the type of the handler to search for
Returns:
the handler registered for the given type

getClientHandlers

java.util.Set<ClientConnectionHandler> getClientHandlers()
Get all registered client handler

Returns:
all available handlers

getSender

WonderlandClientSender getSender(ConnectionType clientType)
Get a sender that can be used to send messages to all clients of a given ConnectionType. This sender can also be used to query all the session connected via the given session type.

Parameters:
clientType - the type of client
Returns:
a sender for sending to all clients of the given type
Throws:
java.lang.IllegalStateException - if no handler is registered for the given type

getWonderlandClientID

WonderlandClientID getWonderlandClientID(java.math.BigInteger sessionID)
Get a WonderlandClientID from a sessionID.

Parameters:
sessionID - BigInteger
Returns:
a WonderlandClientID or null


Open Wonderland - http://openwonderland.org