示例#1
0
        private static void SubscribeToGame(ClientInfo clientInfo, JObject jsonObject, Boolean isSpectator)
        {
            var optionalToken = jsonObject["optional"];

            if ((optionalToken == null) ||
                (optionalToken.Type != JTokenType.Integer))
            {
                Console.WriteLine("Parameters mismatch at Subscribe -- optional.");
                SendMessage(clientInfo, new { exception = "Could not register." });
                return;
            }
            var optional = (int)optionalToken;

            // Check if game exists.
            if (sl.getGameById(optional) != null)
            {
                // Subscribe this channel to game.
                sl.SubscribeToGameState(new ServerObserver(clientInfo), (int)optionalToken, isSpectator);
            }
        }