Exemple #1
0
 void InitChannel(Socket socket, int bufferSize)
 {
     Channel = new WebSocketChannel(socket, bufferSize);
     Channel.onReceiveData   += OnReceiveData;
     Channel.onShutdown      += OnShutdown;
     Channel.onUpgradeResult += OnUpgradeResult;
     Channel.RequestUpgrade();
 }
Exemple #2
0
 private void OnUpgradeResult(WebSocketChannel channel, bool success)
 {
     if (true == success)
     {
         onConnectSuccess?.Invoke(this);
     }
     else
     {
         onConnectFail?.Invoke(this);
     }
 }
Exemple #3
0
 private void OnUpgradeResult(WebSocketChannel channel, bool success)
 {
     channel.onUpgradeResult -= OnUpgradeResult;
     if (success)
     {
         onClientEnter?.Invoke(channel);
     }
     else
     {
         channel.Close();
     }
 }
Exemple #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;
            }
        }