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
    Modifier and Type
    Field
    Description
    private static org.slf4j.Logger
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.mina.core.session.IoSession
    makeClient​(int port)
    Use the returned session to read and write to the server.
    void
    messageReceived​(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.
    void
    messageSent​(org.apache.mina.core.session.IoSession session, Object message)
    void
    sessionClosed​(org.apache.mina.core.session.IoSession session)
     

    Methods inherited from class org.apache.mina.core.service.IoHandlerAdapter

    event, exceptionCaught, inputClosed, sessionCreated, sessionIdle, sessionOpened

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 Exception
      publish the received message with the LOCAL level the same as the original server's level. Recreate the senders logging message with level and logger eg TRACE [name.moore.kevin.ze.zodiac] Entering application state STRATEGIC
      Specified by:
      messageReceived in interface org.apache.mina.core.service.IoHandler
      Overrides:
      messageReceived in class org.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:
      messageSent in interface org.apache.mina.core.service.IoHandler
      Overrides:
      messageSent in class org.apache.mina.core.service.IoHandlerAdapter
      Throws:
      Exception
    • sessionClosed

      public void sessionClosed(org.apache.mina.core.session.IoSession session) throws Exception
      Specified by:
      sessionClosed in interface org.apache.mina.core.service.IoHandler
      Overrides:
      sessionClosed in class org.apache.mina.core.service.IoHandlerAdapter
      Throws:
      Exception