Exemple #1
0
        private void HandleCommunication(ManagedClient client)
        {
            CSLogger.Log($"Client {client.Id} connected ");

            while (client.IsConnected())
            {
                Message message = client.GetMessage();


                switch (state.Value)
                {
                case CSState.Listening:
                    ProcessClientMessageDuringListening(message, client);
                    break;

                case CSState.AgentsAccepting:
                    ProcessAgentMessageDuringAgentsAccepting(message, client);
                    break;

                case CSState.GameInProgress:
                    ProcessAgentMessageDuringGameInProgress(message, client);
                    break;
                }
            }

            if (client.IsInGame)
            {
                HandlePlayerDisconnected(client);
            }

            CSLogger.Log($"Client {client.Id} disconnected ");
        }
Exemple #2
0
        private void HandleGmCommunication(ManagedClient client)
        {
            while (client.IsConnected())
            {
                Message message = client.GetMessage();


                switch (state.Value)
                {
                case CSState.AgentsAccepting:
                    ProcessGmMessageDuringAgentsAccepting(message, client);
                    break;

                case CSState.GameInProgress:
                    ProcessGmMessageDuringGameInProgress(message, client);
                    break;

                case CSState.GameFinished:
                    ProcessGmMessageDuringGameFinished(message, client);
                    break;
                }
            }

            if (client.Id == gmId.Value)
            {
                HandleGMDisconnected();
            }
        }