Exemplo n.º 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);
        }
Exemplo n.º 2
0
Arquivo: Client.cs Projeto: inrg/D2NG
 /// <summary>
 /// Leave current game
 /// </summary>
 public void LeaveGame()
 {
     Log.Information("Leaving game");
     D2gs.LeaveGame();
     Bncs.LeaveGame();
     RealmLogon();
     Mcp.CharLogon(_character);
 }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public void Disconnect()
        {
            if (Bncs.IsConnected())
            {
                Bncs.Disconnect();
            }

            if (Mcp.IsConnected())
            {
                Mcp.Disconnect();
            }

            if (D2gs.IsConnected())
            {
                D2gs.Disconnect();
            }
        }
Exemplo n.º 5
0
 public void OnSentPacketEvent(byte type, Action <D2gsPacket> action)
 => D2gs.OnSentPacketEvent(type, action);
Exemplo n.º 6
0
 public void OnReceivedPacketEvent(byte type, Action <D2gsPacket> action)
 => D2gs.OnReceivedPacketEvent(type, action);
Exemplo n.º 7
0
 public void OnSentPacketEvent(OutGoingPacket type, Action <D2gsPacket> action)
 => D2gs.OnSentPacketEvent(type, action);
Exemplo n.º 8
0
 public void OnReceivedPacketEvent(InComingPacket type, Action <D2gsPacket> action)
 => D2gs.OnReceivedPacketEvent(type, action);