void startServer() { stopServer(); listenerQueue.onStart(); messageServerThread = new ServerThread( SysConstant.MESSAGE_PORT, XFileChannelInitializer.InitialType.SERVERMESSAGEHANDLER); messageServerThread.start(); }
void stopServer() { if (messageServerThread != null) { messageServerThread.stopServer(); messageServerThread = null; listenerQueue.onDestory(); } if (AuthChannelHandlerContext != null) { AuthChannelHandlerContext.close(); AuthChannelHandlerContext = null; } }
public void sendMessage( ChannelHandlerContext ctx, short serviceId, short commandId, GeneratedMessage msg, Packetlistener packetlistener, short seqnum) { if (ctx != null) { Header header = new Header(); header.setCommandId(commandId); header.setServiceId(serviceId); if (seqnum != 0) { header.setSeqnum(seqnum); } if (packetlistener != null && seqnum == 0) { short reqSeqnum = header.getSeqnum(); listenerQueue.push(reqSeqnum, packetlistener); } header.setLength(SysConstant.HEADER_LENGTH + msg.getSerializedSize()); messageServerThread.sendMessage(ctx, header, msg); } }