public bool Listen(ushort port, BaseNet.OnAcceptFunction accept, BaseNet.OnReceiveFunction receive, BaseNet.OnCloseFunction close) { OnAccept = accept; OnReceive = receive; OnClose = close; m_socket = new TCPServerSocket(); m_socket.OnOpen += OnAcceptConnect; m_socket.OnMessage += OnMessageReveived; m_socket.OnClose += OnConnectClose; return(m_socket.Start(port)); }
public override void Close() { if (m_socket != null) { m_socket.Close(); m_socket = null; } //需要放m_socket.Close()后,socket关闭时,内部回调的关闭事件HanldeCloseConnect不能正常执行 foreach (var obj in m_channels) { obj.Value.Destroy(); NetChannelPools.Despawn(obj.Value); } m_channels.Clear(); base.Close(); }