// handle incoming clients private async Task HandleClient(ConnectionStream stream) { if (!(await HandshakeClient(stream))) { return; } WebsockServerClient serverClient = new WebsockServerClient(this, ref stream); clients.Add(serverClient); await serverClient.StartAsync(); }
// handle a new client connection private async Task HandleClient(TcpClient client, Stream stream) { // first, handshake with the client if (!(await HandshakeClient(client, stream))) { return; } // then, create client and add to stream WebsockServerClient serverClient = new WebsockServerClient(this, ref stream, ref client); clients.Add(serverClient); OnConnect(serverClient); await serverClient.StartAsync(); }