org.apache.mina.example.gettingstarted.timeserver
Class TimeServerHandler
java.lang.Object
org.apache.mina.core.service.IoHandlerAdapter
org.apache.mina.example.gettingstarted.timeserver.TimeServerHandler
- All Implemented Interfaces:
- IoHandler
public class TimeServerHandler
- extends IoHandlerAdapter
The Time Server handler : it return the current date when a message is received,
or close the session if the "quit" message is received.
- Author:
- Apache MINA Project
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
TimeServerHandler
public TimeServerHandler()
exceptionCaught
public void exceptionCaught(IoSession session,
Throwable cause)
throws Exception
- Trap exceptions.
- Specified by:
exceptionCaught
in interface IoHandler
- Overrides:
exceptionCaught
in class IoHandlerAdapter
- Throws:
Exception
messageReceived
public void messageReceived(IoSession session,
Object message)
throws Exception
- If the message is 'quit', we exit by closing the session. Otherwise,
we return the current date.
- Specified by:
messageReceived
in interface IoHandler
- Overrides:
messageReceived
in class IoHandlerAdapter
- Throws:
Exception
sessionIdle
public void sessionIdle(IoSession session,
IdleStatus status)
throws Exception
- On idle, we just write a message on the console
- Specified by:
sessionIdle
in interface IoHandler
- Overrides:
sessionIdle
in class IoHandlerAdapter
- Throws:
Exception
Copyright © 2004-2012 Apache MINA Project. All Rights Reserved.