public class ChatProtocolHandler extends IoHandlerAdapter
IoHandler
implementation of a simple chat server protocol.Constructor and Description |
---|
ChatProtocolHandler() |
Modifier and Type | Method and Description |
---|---|
void |
broadcast(String message) |
void |
exceptionCaught(IoSession session,
Throwable cause)
Invoked when any exception is thrown by user
IoHandler
implementation or by MINA. |
int |
getNumberOfUsers() |
boolean |
isChatUser(String name) |
void |
kick(String name) |
void |
messageReceived(IoSession session,
Object message)
Invoked when a message is received.
|
void |
sessionClosed(IoSession session)
Invoked when a connection is closed.
|
inputClosed, messageSent, sessionCreated, sessionIdle, sessionOpened
public ChatProtocolHandler()
public void exceptionCaught(IoSession session, Throwable cause)
IoHandlerAdapter
IoHandler
implementation or by MINA. If cause
is an instance of
IOException
, MINA will close the connection automatically.exceptionCaught
in interface IoHandler
exceptionCaught
in class IoHandlerAdapter
session
- The session for which we have got an exceptioncause
- The exception that has been caughtpublic void messageReceived(IoSession session, Object message)
IoHandlerAdapter
messageReceived
in interface IoHandler
messageReceived
in class IoHandlerAdapter
session
- The session that is receiving a messagemessage
- The received messagepublic void sessionClosed(IoSession session) throws Exception
IoHandlerAdapter
sessionClosed
in interface IoHandler
sessionClosed
in class IoHandlerAdapter
session
- The session being closedException
- If we get an exception while processing the close eventpublic boolean isChatUser(String name)
public int getNumberOfUsers()
Copyright © 2004–2016 Apache MINA Project. All rights reserved.