Пример #1
0
        private static void AddMessage(ClientInfo client, JObject jsonObject)
        {
            var gameIdToken      = jsonObject["gameId"];
            var userIdToken      = jsonObject["userId"];
            var messageTextToken = jsonObject["messageText"];

            if (((gameIdToken == null) || (gameIdToken.Type != JTokenType.Integer)) ||
                ((userIdToken == null) || (userIdToken.Type != JTokenType.Integer)) ||
                ((messageTextToken == null) || (messageTextToken.Type != JTokenType.String)))
            {
                throw new ArgumentException("Error: Parameters Mismatch at Add Message.");
            }

            var gameId      = (int)gameIdToken;
            var userId      = (int)userIdToken;
            var messageText = (string)messageTextToken;

            Console.WriteLine("Message added. parameters are: gameId: {0}, userId: {1}, messageText: {2}", gameId, userId, messageText);

            SendMessage(client, new { response = sl.AddMessage(gameId, userId, messageText) });
        }