Class clientHandler
java.lang.Object
org.apache.mina.core.service.IoHandlerAdapter
name.moore.kevin.ze.game.states.remote.clientHandler
- All Implemented Interfaces:
org.apache.mina.core.service.IoHandler
public class clientHandler
extends org.apache.mina.core.service.IoHandlerAdapter
Accept incoming message objects from and send messages to the zodiac remote server.
Since the remote server uses a Log4j Appender to transmit, the received messages are Log4J LoggingEvents. But we are using Slf4j, so care to use the right package's 'Level' etc.
- Author:
- Kevin Moore
<dev@kevin.moore.name> - See Also:
remoteState
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.mina.core.session.IoSessionmakeClient(int port)Use the returned session to read and write to the server.voidmessageReceived(org.apache.mina.core.session.IoSession session, Object message)publish the received message with the LOCAL level the same as the original server's level.voidmessageSent(org.apache.mina.core.session.IoSession session, Object message)voidsessionClosed(org.apache.mina.core.session.IoSession session)Methods inherited from class org.apache.mina.core.service.IoHandlerAdapter
event, exceptionCaught, inputClosed, sessionCreated, sessionIdle, sessionOpened
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER
-
-
Constructor Details
-
clientHandler
public clientHandler()
-
-
Method Details
-
makeClient
public static org.apache.mina.core.session.IoSession makeClient(int port)Use the returned session to read and write to the server.- Parameters:
port-- Returns:
-
messageReceived
public void messageReceived(org.apache.mina.core.session.IoSession session, Object message) throws Exceptionpublish the received message with the LOCAL level the same as the original server's level. Recreate the senders logging message with level and logger egTRACE [name.moore.kevin.ze.zodiac] Entering application state STRATEGIC- Specified by:
messageReceivedin interfaceorg.apache.mina.core.service.IoHandler- Overrides:
messageReceivedin classorg.apache.mina.core.service.IoHandlerAdapter- Parameters:
message- org.apache.log4j.spi.LoggingEvent (since InternalAppender is log4j)- Throws:
Exception
-
messageSent
public void messageSent(org.apache.mina.core.session.IoSession session, Object message) throws Exception- Specified by:
messageSentin interfaceorg.apache.mina.core.service.IoHandler- Overrides:
messageSentin classorg.apache.mina.core.service.IoHandlerAdapter- Throws:
Exception
-
sessionClosed
- Specified by:
sessionClosedin interfaceorg.apache.mina.core.service.IoHandler- Overrides:
sessionClosedin classorg.apache.mina.core.service.IoHandlerAdapter- Throws:
Exception
-