public NetworkTask(string name, Action callback) { Name = name; Callback = callback; CurrentTask = this; }
/// <summary> /// Connects to the server. /// </summary> public void Connect() { if (this.ServerIP == null) { throw new ArgumentNullException(nameof(this.ServerIP), "The value must not be null"); } this.connection.Connect(new IPEndPoint(this.ServerIP, 1337)); if (!this.connection.Connected) { this.FireConnectionFailed(this, EventArgs.Empty); return; } this.sendAliveMessageTask = new SendAliveMessageTask(this.connection); this.sendAliveMessageTask.Start(null, true); this.connection.StartListening(); }
/// <summary> /// Starts sending lobby requests. /// </summary> public void StartSendingLobbyRequests() { this.sendLobbyRequestTask = new SendLobbyRequestTask(this.connection); this.sendLobbyRequestTask.Start(null, true); }
private void FinishTask() { CurrentTask = null; Callback(); }