Package com.jme3.network.util
Class SessionDataDelegator
java.lang.Object
com.jme3.network.util.AbstractMessageDelegator<HostedConnection>
com.jme3.network.util.SessionDataDelegator
- All Implemented Interfaces:
MessageListener<HostedConnection>
A MessageListener implementation that will forward messages to methods
of a delegate specified as a HostedConnection session attribute. This is
useful for handling connection-specific messages from clients that must
delegate to client-specific data objects.
The delegate methods can be automapped or manually specified.
-
Constructor Summary
ConstructorDescriptionSessionDataDelegator
(Class delegateType, String attributeName, boolean automap) Creates a MessageListener that will forward mapped message types to methods of an object specified as a HostedConnection attribute. -
Method Summary
Modifier and TypeMethodDescriptionReturns the attribute name that will be used to look up the delegate object.protected Object
getSourceDelegate
(HostedConnection source) Returns the attributeName attribute of the supplied source HostConnection.protected void
miss
(HostedConnection source) Called internally when there is no session object for the current attribute name attached to the passed source HostConnection.Methods inherited from class com.jme3.network.util.AbstractMessageDelegator
allowName, automap, findDelegate, getMessageType, getMessageTypes, getMethod, isValidMethod, map, map, map, messageReceived
-
Constructor Details
-
SessionDataDelegator
Creates a MessageListener that will forward mapped message types to methods of an object specified as a HostedConnection attribute. If automap is true then all methods with the proper signature will be mapped.Methods of the following signatures are allowed:
- void someName(S conn, SomeMessage msg)
- void someName(Message msg)
-
-
Method Details
-
getAttributeName
Returns the attribute name that will be used to look up the delegate object. -
miss
Called internally when there is no session object for the current attribute name attached to the passed source HostConnection. Default implementation logs a warning. -
getSourceDelegate
Returns the attributeName attribute of the supplied source HostConnection. If there is no value at that attribute then the miss() method is called.- Specified by:
getSourceDelegate
in classAbstractMessageDelegator<HostedConnection>
-