Пример #1
0
 public override void Dispose()
 {
     _client.Dispose();
     _client.Disconnected   -= OnDisconnected;
     _client.Error          -= OnError;
     _client.PacketReceived -= OnPacketReceived;
 }
Пример #2
0
        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);
            }
        }
Пример #3
0
 public override void Dispose()
 {
     base.Dispose();
     _client.Dispose(); // Events unsubscribed
 }
Пример #4
0
 public void Dispose()
 {
     _client.Dispose(); // Unsubscribe events
 }