public bool Connect(string host, ushort port) { if (_client.Connect(new IPEndPoint(IPAddress.Parse(host), port), 10 * 1000)) { OnConnected(); return(true); } return(false); }
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); } }