Beispiel #1
0
        /// <summary>
        /// On a new thread setup all the required information
        /// </summary>
        /// <param name="newClient">The TcpClient used for communication</param>
        private void SetupNewClient(TcpClient newClient)
        {
            var serverReference = new ServerClientReference(Guid.NewGuid(), newClient, OnClientStatusChanged, ListenerCancelToken);

            serverReference.OnClientWon += OnWinnerFound;
            OnClientStatusChanged?.Invoke(serverReference, ConnectionType.Connected);
        }
Beispiel #2
0
        private void InternalClientEventChange(ServerClientReference Client, ConnectionType Connection)
        {
            switch (Connection)
            {
            case ConnectionType.Connected:
                ConnectedClients.TryAdd(Client.ID, Client);
                break;

            case ConnectionType.Disconnected:
                ConnectedClients.TryRemove(Client.ID, out ServerClientReference oldClient);
                oldClient.Dispose();
                break;
            }
        }