public class ChatProtocolHandler extends IoHandlerAdapter
IoHandler
implementation of a simple chat server protocol.构造器和说明 |
---|
ChatProtocolHandler() |
限定符和类型 | 方法和说明 |
---|---|
void |
broadcast(java.lang.String message) |
void |
exceptionCaught(IoSession session,
java.lang.Throwable cause)
Invoked when any exception is thrown by user
IoHandler
implementation or by MINA. |
int |
getNumberOfUsers() |
boolean |
isChatUser(java.lang.String name) |
void |
kick(java.lang.String name) |
void |
messageReceived(IoSession session,
java.lang.Object message)
Invoked when a message is received.
|
void |
sessionClosed(IoSession session)
Invoked when a connection is closed.
|
inputClosed, messageSent, sessionCreated, sessionIdle, sessionOpened
public void exceptionCaught(IoSession session, java.lang.Throwable cause)
IoHandlerAdapter
IoHandler
implementation or by MINA. If cause
is an instance of
IOException
, MINA will close the connection automatically.exceptionCaught
在接口中 IoHandler
exceptionCaught
在类中 IoHandlerAdapter
session
- The session for which we have got an exceptioncause
- The exception that has been caughtpublic void messageReceived(IoSession session, java.lang.Object message)
IoHandlerAdapter
messageReceived
在接口中 IoHandler
messageReceived
在类中 IoHandlerAdapter
session
- The session that is receiving a messagemessage
- The received messagepublic void broadcast(java.lang.String message)
public void sessionClosed(IoSession session) throws java.lang.Exception
IoHandlerAdapter
sessionClosed
在接口中 IoHandler
sessionClosed
在类中 IoHandlerAdapter
session
- The session being closedjava.lang.Exception
- If we get an exception while processing the close eventpublic boolean isChatUser(java.lang.String name)
public int getNumberOfUsers()
public void kick(java.lang.String name)