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