.flip());
}
}
public static void main(String[] args) throws Exception {
SessionAcceptor acceptor = SessionFactory
.createSessionAcceptor(SessionType.TCP);
acceptor.setAcceptorHandler(new SessionAcceptorHandler() {
public void sessionAccepted(SessionAcceptor acceptor,
Session session) throws Exception {
session.setPacketDecoder(new ChatMessageDecoder());
session.setPacketEncoder(new ChatMessageEncoder());
session.addSessionFilter(new ChatLogFilter());
session.setSessionHandler(new ChatHandler());
session.start();
}
public void exceptionCaught(SessionAcceptor acceptor,
Throwable cause) {
System.err.println(cause);
}
});
acceptor.start();
if (acceptor.isStarted())
System.out.println("ChatServer listen on "
+ acceptor.getListenAddress());
}