public override void Dispose() { _client.Dispose(); _client.Disconnected -= OnDisconnected; _client.Error -= OnError; _client.PacketReceived -= OnPacketReceived; }
private byte _battleId = byte.MaxValue; // Spectator by default public NetworkClientConnection(string host, ushort port, PBELegalPokemonCollection party, Action <object> action) { _party = party; _action = action; _client = new PBEClient(); _client.Disconnected += OnDisconnected; _client.Error += OnError; _client.PacketReceived += OnPacketReceived; if (_client.Connect(new IPEndPoint(IPAddress.Parse(host), port), 10 * 1000)) { OnConnected(); } else { _client.Dispose(); action.Invoke(null); } }
public override void Dispose() { base.Dispose(); _client.Dispose(); // Events unsubscribed }
public void Dispose() { _client.Dispose(); // Unsubscribe events }