Example #1
0
        public bool Listen(string host, BaseNet.OnAcceptFunction accept, BaseNet.OnReceiveFunction receive, BaseNet.OnCloseFunction close)
        {
            OnAccept  = accept;
            OnReceive = receive;
            OnClose   = close;

            m_socket            = new WebServerSocket();
            m_socket.OnOpen    += OnAcceptConnect;
            m_socket.OnMessage += OnMessageReveived;
            m_socket.OnClose   += OnConnectClose;
            return(m_socket.Start(host));
        }
Example #2
0
 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();
 }