public void AddUserToPlayerList(string token, string userPuid)
        {
            GameSession gs = (GameSession)GameRegistry.GetClientSession(token);

            if (gs != null)
            {
                string userToken = UserRegistry.GetToken(userPuid);
                if (userToken != null)
                {
                    gs.AddUserToPlayerList(userPuid, userToken);
                    Console.WriteLine("> Event: @username:{" + userPuid + "} joined @GameServer:{" + gs.PUID + "}");
                }
                else
                {
                    Console.WriteLine("> Illegal Event: @username:{" + userPuid + "} joined @GameServer:{" + gs.PUID + "}");
                    Console.WriteLine("> Reason: @username:{" + userPuid + "} has invaild session token:{" + userToken + "}");
                }
            }
            else
            {
                Console.WriteLine("> Illegal Event: @username:{" + userPuid + "} joined unknown GameServer!");
            }
        }
示例#2
0
        private void ApplyEffect(List <string> targets, AbilityEffect ae, int magnitude)
        {
            PlayerSession player = null;

            foreach (string target in targets)
            {
                player = (PlayerSession)PlayerRegistry.GetClientSession(PlayerRegistry.GetToken(target));
                if (player != null && player.IsTargetable())
                {
                    ApplyEffect(player.PlayerHero, ae, magnitude);
                }
                else if (target == Boss.PUID)
                {
                    ApplyEffect(GameBoss, ae, magnitude);
                }
            }
        }
        public bool PingGameServer(string serverName)
        {
            bool        result    = false;
            string      gameToken = GameRegistry.GetToken(serverName);
            GameSession gs        = (GameSession)GameRegistry.GetClientSession(gameToken);

            if (gs != null)
            {
                try
                {
                    // The ping test fails if any kind of Exception is thrown
                    result = gs.CallbackChannel.GamePortalServer_OnPing();
                } catch (Exception) {
                    // Ping failed!
                }
            }

            return(result);
        }