コード例 #1
0
    public NetworkTask(string name, Action callback)
    {
        Name     = name;
        Callback = callback;

        CurrentTask = this;
    }
コード例 #2
0
        /// <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();
        }
コード例 #3
0
 /// <summary>
 /// Starts sending lobby requests.
 /// </summary>
 public void StartSendingLobbyRequests()
 {
     this.sendLobbyRequestTask = new SendLobbyRequestTask(this.connection);
     this.sendLobbyRequestTask.Start(null, true);
 }
コード例 #4
0
 private void FinishTask()
 {
     CurrentTask = null;
     Callback();
 }