2. The code is copied, but in this method
@Override public void messageReceived(IoSession session, Object message) throws Exception { ClientRequest clientRequest = (ClientRequest) message; AppSession appSession = AppSession.getInstance(session); if (appSession == null) { return; } GameServer.msgDispatcher.dispatchMsg(appSession, clientRequest); }
did this in
if (appSession == null) { return; }
3. The client sends data immediately after creating the socket. As a result, there is a waiting crash, and it stays in the state of waiting for data acquisition.
4. After analyzing for a long time, I located the above code. Why is appSession empty,
in
public void sessionOpened(IoSession session) throws Exception { AppSession appSession = new AppSession(session); appSession.holdInIoSession(); logger.info("a session create from ip {}", session.getRemoteAddress()); }
In this code, the AppSession has been put into the IoSession as a payload
5. But it is not obtained, and the value can be obtained when the tracking of the breakpoint is interrupted. It is estimated that the put operation of the service segment is not completed because the client sends data too fast. Just get the client's data request and enter the messageReceived method, so temporarily stop for 100 milliseconds after the client creates a connection, the server does not encounter similar problems