public async Task Connect(ConnectionInfo connectionInfo) { Disconnect(); CurrentServerInfo = connectionInfo; Client = new Client(); Client.ServerConnectionFailed += OnServerConnectionFailed; Client.ServerConnectionDropped += OnServerConnectionDropped; Client.ServerConnectionSucceeded += OnServerConnectionSucceeded; Client.ServerConnectionStarting += OnServerConnectionStarting; Client.ServerConnectionDisconnected += OnServerConnectionDisconnected; Client.ReceivedPacket += OnReceivedPacket; await Client.Connect(CurrentServerInfo.Hostname, CurrentServerInfo.Port); }
public async Task Connect(ConnectionInfo connectionInfo) { // Connect can be called while we're already connected to a server so disconnect first Disconnect(); CurrentServerInfo = connectionInfo; Client = new Client(); Client.ServerConnectionFailed += OnServerConnectionFailed; Client.ServerConnectionDropped += OnServerConnectionDropped; Client.ServerConnectionSucceeded += OnServerConnectionSucceeded; Client.ServerConnectionStarting += OnServerConnectionStarting; Client.ServerConnectionDisconnected += OnServerConnectionDisconnected; Client.ReceivedPacket += OnReceivedPacket; await Client.Connect(CurrentServerInfo.Hostname, CurrentServerInfo.Port); }
public Keepalive(Client client) { Client = client; Timer = new Stopwatch(); Timer.Restart(); }