/// <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); }
public void Disconnect() { if (Bncs.IsConnected()) { Bncs.Disconnect(); } if (Mcp.IsConnected()) { Mcp.Disconnect(); } if (D2gs.IsConnected()) { D2gs.Disconnect(); } }