void AcceptedClientCallback(System.IAsyncResult ar) { DebugLogging("Server: Client Connected"); TcpClient client = (ar.AsyncState as TcpListener).EndAcceptTcpClient(ar); ClientDataContainer_ForTool c = new ClientDataContainer_ForTool() { TcpSocket = client, address = ((IPEndPoint)client.Client.RemoteEndPoint).Address, NetworkId = NetIdBuffer++ }; DebugLogging("Client IPAddress : " + c.address); ClientDataList.Add(c); OnNewClientConnected?.Invoke(c); }
private void listenTaskRoutine() { CancellationToken token = cancellationTokenSrc.Token; while (!token.IsCancellationRequested) { if (listener.Pending()) { TcpSignalizationClient client = new TcpSignalizationClient(listener.AcceptTcpClient()); OnNewClientConnected?.BeginInvoke(client, null, null); } else { Thread.Sleep(100); } } }