/// <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); }
/// <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()); }
/// <summary> /// Leave current game /// </summary> public void LeaveGame() { Log.Information("Leaving game"); D2gs.LeaveGame(); Bncs.LeaveGame(); RealmLogon(); Mcp.CharLogon(_character); }
/// <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); }
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}"); }
/// <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()); }
public void Disconnect() { if (Bncs.IsConnected()) { Bncs.Disconnect(); } if (Mcp.IsConnected()) { Mcp.Disconnect(); } if (D2gs.IsConnected()) { D2gs.Disconnect(); } }
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); }
/// <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);
public void OnSentPacketEvent(Sid sid, Action <BncsPacket> action) => Bncs.OnSentPacketEvent(sid, action);
public void OnReceivedPacketEvent(Sid sid, Action <BncsPacket> action) => Bncs.OnReceivedPacketEvent(sid, action);
private void LeaveGame() { Bncs.LeaveGame(); RealmLogon(); Mcp.CharLogon(_character); }
/// <summary> /// Connect to a Battle.net Realm /// </summary> public bool Connect(string realm, string keyOwner, string gamefolder) => Bncs.ConnectTo(realm, keyOwner, gamefolder);