Example #1
0
        /// <summary>
        /// Handles the JoinGameIn packet. This packet is sent in response to our request to join
        /// a game. If successful, we fire an event to notify the driver to start the game server.
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnJoinGame(RealmServerPacket packet)
        {
            JoinGameIn fromServer = new JoinGameIn(packet);

            LogServer(fromServer);

            if (!fromServer.IsSuccessful())
            {
                Fail(FailureArgs.FailureTypes.FailedToJoinGame, fromServer.ToString());
                return;
            }

            GameServerArgs args = new GameServerArgs();

            args.Address        = fromServer.GameServerIp.ToString();
            args.Port           = 4000;
            args.GameHash       = fromServer.GameHash;
            args.GameToken      = fromServer.GameToken;
            args.CharacterClass = (byte)CharacterClassType.Barbarian;
            args.PlayerCount    = playerCount;
            args.MaxPlayers     = maxPlayers;
            args.PlayerNames    = playerNames;

            // Pad the character name to 16 bytes. This is required by the game server.
            byte[] charNameBytes = ASCIIEncoding.ASCII.GetBytes(characterName);
            Array.Resize(ref charNameBytes, 16);
            args.CharacterName = (byte[])charNameBytes.Clone();

            ReadyToConnectToGameServer(this, args);
        }
 /// <summary>
 /// raised when client is ready to connect to the game server
 /// </summary>
 /// <param name="sender">Object causing this event</param>
 /// <param name="e">Arguments needed to connect to the game server</param>
 private void realmServer_ReadyToConnectToGameServer(object sender, GameServerArgs e)
 {
     Log("RealmServer says we're ready to connect to game server");
     gameServerThread.Start(e);
     realmServer.Disconnect();
 }
        /// <summary>
        /// Handles the JoinGameIn packet. This packet is sent in response to our request to join
        /// a game. If successful, we fire an event to notify the driver to start the game server.
        /// </summary>
        /// <param name="packet">The packet.</param>
        private void OnJoinGame(RealmServerPacket packet)
        {
            JoinGameIn fromServer = new JoinGameIn(packet);
            LogServer(fromServer);

            if (!fromServer.IsSuccessful())
            {
                Fail(FailureArgs.FailureTypes.FailedToJoinGame, fromServer.ToString());
                return;
            }

            GameServerArgs args = new GameServerArgs();
            args.Address = fromServer.GameServerIp.ToString();
            args.Port = 4000;
            args.GameHash = fromServer.GameHash;
            args.GameToken = fromServer.GameToken;
            args.CharacterClass = (byte)CharacterClassType.Barbarian;
            args.PlayerCount = playerCount;
            args.MaxPlayers = maxPlayers;
            args.PlayerNames = playerNames;

            // Pad the character name to 16 bytes. This is required by the game server.
            byte[] charNameBytes = ASCIIEncoding.ASCII.GetBytes(characterName);
            Array.Resize(ref charNameBytes, 16);
            args.CharacterName = (byte[])charNameBytes.Clone();

            ReadyToConnectToGameServer(this, args);
        }