根据打印的错误信息:at org.apache.mina.handler.demux.DemuxingIoHandler.messageSent(DemuxingIoHandler.java:253)
找不到handler ,因为有类ServerHandler extends DemuxingIoHandler 而在addSentMessageHandler这个方法没有添加对应的类型和handler,所以报错
public ServerHandle(){
MessageObjectInnerHandler handler = new MessageObjectInnerHandler();
addReceivedMessageHandler(MessageObject.class, handler);
}
重写方法messageSent ,注释掉super.messageSent(session, message),这样发送的时候就不会调用messageSent,验证消息类型了。
@Override
public void messageSent(IoSession session, Object message) throws Exception {
// TODO Auto-generated method stub
//super.messageSent(session, message);
}