コード例 #1
0
        private void ReceiveMessage(SocketState state)
        {
            if (state.ErrorOccured)
            {
                RemoveClient(state);
                return; // Want to handle this situation
            }
            // This is the callback for all recieved movement commands associated with a client
            // Do stuff with recieved movement commands
            List <string> extractedData = ExtractSocketData(state);

            foreach (string json in extractedData)
            {
                if (TryParseJsonAsTankControlCommand(json, out TankControlCommand tankControlCommand))
                {
                    gameController.UpdateGameControlState(clientToPlayerMap[state.ID], tankControlCommand);
                }
                // Will do nothing if malformed JSON is recieved
            }

            Networking.GetData(state);
        }