예제 #1
0
 void InitChannel(Socket socket, int bufferSize)
 {
     Channel = new WebSocketChannel(socket, bufferSize);
     Channel.onReceiveData   += OnReceiveData;
     Channel.onShutdown      += OnShutdown;
     Channel.onUpgradeResult += OnUpgradeResult;
     Channel.RequestUpgrade();
 }
예제 #2
0
 private void OnUpgradeResult(WebSocketChannel channel, bool success)
 {
     if (true == success)
     {
         onConnectSuccess?.Invoke(this);
     }
     else
     {
         onConnectFail?.Invoke(this);
     }
 }
예제 #3
0
 private void OnUpgradeResult(WebSocketChannel channel, bool success)
 {
     channel.onUpgradeResult -= OnUpgradeResult;
     if (success)
     {
         onClientEnter?.Invoke(channel);
     }
     else
     {
         channel.Close();
     }
 }
예제 #4
0
        void Enter(Socket clientSocket)
        {
            WebSocketChannel channel = new WebSocketChannel(clientSocket, _bufferSize);

            _channelList.Add(channel);
            Log.I("新的连接,连接总数:{0}", ClientCount);

            channel.onShutdown += OnClientShutdown;

            if (channel.IsUpgrade)
            {
                OnUpgradeResult(channel, true);
            }
            else
            {
                channel.onUpgradeResult += OnUpgradeResult;
            }
        }