Beispiel #1
0
        /// <summary>
        /// Join a game
        /// </summary>
        /// <param name="name">Name of the game being joined</param>
        /// <param name="password">Password used to protect the game</param>
        public bool JoinGame(string name, string password)
        {
            Log.Information($"Joining game: {name} with {LoggedInUserName()}");
            var packet = Mcp.JoinGame(name, password);

            if (packet == null)
            {
                return(false);
            }

            if (packet.Result != 0x00)
            {
                return(false);
            }

            Mcp.Disconnect();
            Log.Debug($"Connecting to D2GS Server {packet.D2gsIp}");
            try
            {
                D2gs.Connect(packet.D2gsIp);
            }
            catch
            {
                D2gs.Disconnect();
                return(false);
            }

            if (!D2gs.GameLogon(packet.GameHash, packet.GameToken, _character))
            {
                D2gs.Disconnect();
                return(false);
            }
            Bncs.NotifyJoin(name, password);
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Join a game
        /// </summary>
        /// <param name="name">Name of the game being joined</param>
        /// <param name="password">Password used to protect the game</param>
        public void JoinGame(string name, string password)
        {
            Log.Information($"Joining game: {name}");
            var packet = Mcp.JoinGame(name, password);

            Mcp.Disconnect();
            Log.Debug($"Connecting to D2GS Server {packet.D2gsIp}");
            D2gs.Connect(packet.D2gsIp);
            D2gs.GameLogon(packet.GameHash, packet.GameToken, _character);
            Bncs.NotifyJoin(name, password);
        }