Esempio 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);
        }
Esempio n. 2
0
 /// <summary>
 /// Login to Battle.Net with credentials and receive the list of available characters to select.
 /// </summary>
 /// <param name="username">Account name</param>
 /// <param name="password">Password used to login</param>
 /// <returns>A list of Characters associated with the account</returns>
 public List <Character> Login(string username, string password)
 {
     Bncs.Login(username, password);
     Log.Information($"Logged in as {username}");
     RealmLogon();
     return(Mcp.ListCharacters());
 }
Esempio n. 3
0
File: Client.cs Progetto: inrg/D2NG
 /// <summary>
 /// Leave current game
 /// </summary>
 public void LeaveGame()
 {
     Log.Information("Leaving game");
     D2gs.LeaveGame();
     Bncs.LeaveGame();
     RealmLogon();
     Mcp.CharLogon(_character);
 }
Esempio n. 4
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);
        }
Esempio n. 5
0
        private void RealmLogon()
        {
            if (_mcpRealm is null)
            {
                _mcpRealm = Bncs.ListMcpRealms().First();
            }
            var packet = Bncs.RealmLogon(_mcpRealm);

            Log.Information($"Connecting to {packet.McpIp}:{packet.McpPort}");
            Mcp.Connect(packet.McpIp, packet.McpPort);
            Mcp.Logon(packet.McpCookie, packet.McpStatus, packet.McpChunk, packet.McpUniqueName);
            Log.Information($"Connected to {packet.McpIp}:{packet.McpPort}");
        }
Esempio n. 6
0
        /// <summary>
        /// Login to Battle.Net with credentials and receive the list of available characters to select.
        /// </summary>
        /// <param name="username">Account name</param>
        /// <param name="password">Password used to login</param>
        /// <returns>A list of Characters associated with the account</returns>
        public List <Character> Login(string username, string password)
        {
            if (!Bncs.Login(username, password))
            {
                Log.Warning($"Logged failed as {username}");
                return(null);
            }
            Log.Information($"Logged in as {username}");
            _userName = username;
            if (!RealmLogon())
            {
                return(null);
            }

            return(Mcp.ListCharacters());
        }
Esempio n. 7
0
        public void Disconnect()
        {
            if (Bncs.IsConnected())
            {
                Bncs.Disconnect();
            }

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

            if (D2gs.IsConnected())
            {
                D2gs.Disconnect();
            }
        }
Esempio n. 8
0
        private bool RealmLogon()
        {
            if (_mcpRealm is null)
            {
                _mcpRealm = Bncs.ListMcpRealms()?.First();
            }

            if (_mcpRealm == null)
            {
                Log.Warning("RealmLogin failed, no mcp realm found");
                return(false);
            }

            if (!Bncs.IsConnected())
            {
                return(false);
            }

            var packet = Bncs.RealmLogon(_mcpRealm);

            if (packet == null)
            {
                Log.Warning("RealmLogin failed");
                return(false);
            }

            Log.Debug($"Connecting to {packet.McpIp}:{packet.McpPort}");
            Mcp.Connect(packet.McpIp, packet.McpPort);
            if (!Mcp.Logon(packet.McpCookie, packet.McpStatus, packet.McpChunk, packet.McpUniqueName))
            {
                Log.Warning("RealmLogin Connecting failed");
                return(false);
            }
            Log.Debug($"Connected to MCP {packet.McpIp}:{packet.McpPort}");
            return(true);
        }
Esempio n. 9
0
 /// <summary>
 /// Connect to a Battle.net Realm
 /// </summary>
 /// <param name="realm">Realm to connect to. e.g. useast.battle.net </param>
 /// <param name="classicKey">26-character Diablo II Classic CD Key</param>
 /// <param name="expansionKey">26-character Diablo II: Lord of Destruction CD Key</param>
 public void Connect(string realm, string classicKey, string expansionKey) => Bncs.ConnectTo(realm, classicKey, expansionKey);
Esempio n. 10
0
 public void OnSentPacketEvent(Sid sid, Action <BncsPacket> action)
 => Bncs.OnSentPacketEvent(sid, action);
Esempio n. 11
0
 public void OnReceivedPacketEvent(Sid sid, Action <BncsPacket> action)
 => Bncs.OnReceivedPacketEvent(sid, action);
Esempio n. 12
0
 private void LeaveGame()
 {
     Bncs.LeaveGame();
     RealmLogon();
     Mcp.CharLogon(_character);
 }
Esempio n. 13
0
 /// <summary>
 /// Connect to a Battle.net Realm
 /// </summary>
 public bool Connect(string realm, string keyOwner, string gamefolder)
 => Bncs.ConnectTo(realm, keyOwner, gamefolder);