public void Release() { if (session != null) { session.SetReceiveListener(null); session.Active(false); session = null; } }
private void DoReceiveInThread() { EndPoint remotePoint = IPUtility.GetIPEndPointAny(AddressFamily.InterNetwork, 0); int cnt = systemSocket.ReceiveFrom(recvBufferTemp, recvBufferTemp.Length, SocketFlags.None, ref remotePoint); if (cnt > 0) { recvBufferTempReader.Attach(recvBufferTemp, cnt); byte[] m_32b = new byte[4]; recvBufferTempReader.ReadBytes(m_32b, 0, 4); uint sid = BitConverter.ToUInt32(m_32b, 0); lock (mapSession) { FSPSession session = null; if (sid == 0) { Debuger.LogError("基于KCP的Sid为0,该包需要被丢掉"); } else { if (mapSession.ContainsKey(sid)) { session = mapSession[sid]; } } if (session != null) { session.Active(remotePoint as IPEndPoint); session.DoReceiveInGateway(recvBufferTemp, cnt); } else { Debuger.LogWarning("无效的包! sid:{0}", sid); } } } }