/// <summary> /// Handle with clients /// </summary> /// <param name="cluid">ClientUID</param> public static void HandleClients(string cluid) { try { string clientid = cluid; TcpClient Client; lock (_lock) Client = _DClients[clientid]; if (_newclientDetected) { byte[] buffer = Encoding.ASCII.GetBytes($"/CLIENTNUMBER;{clientid}"); TMainModel.Sendbuf2Client(Client, buffer); } while (true) { NetworkStream stream = Client.GetStream(); byte[] buffer = new byte[2048]; int byte_count = stream.Read(buffer, 0, buffer.Length); if (byte_count == 0) { break; } TMainModel.readCommand(Client, clientid, buffer, byte_count); } Console.WriteLine($"Client {Client.Client.RemoteEndPoint} was disconnected!!"); Logger.Log.Info($"Client {Client.Client.RemoteEndPoint} was disconnected!!"); TMainModel.RemoveClientFromDict(clientid); Client.Client.Shutdown(SocketShutdown.Both); Client.Close(); } catch (Exception ex) { TMainModel.ErrorCatcher(ex, "HandleClients"); } }