Exemple #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServerUser"/> class. 
        /// Connect and login to an IrcServer.
        /// </summary>
        /// <param name="hostName">
        /// </param>
        /// <param name="userName">
        /// </param>
        /// <param name="password">
        /// </param>
        /// <param name="nickName">
        /// </param>
        /// <param name="realName">
        /// </param>
        /// <param name="millisecondsBetweenCommands">
        /// </param>
        public ServerUser(string hostName, string userName, string password, string nickName = null, string realName = null, int millisecondsBetweenCommands = 1000)
        {
            this.HostName = hostName;
            this.UserName = userName;
            this.Password = password;
            this.NickName = nickName ?? userName;
            this.RealName = realName ?? this.NickName;
            this.SecondsBetweenCommands = millisecondsBetweenCommands / 1000.0;
            this.CommandPrefix = "This ain't going to happen";

            this.Client = new IrcClient();

            EventDispatcher.Add(this);

            // Connect
            this.Wait();
            this.Client.Connect(this.HostName);
            this.CommandSent();
            var waiter = new Waiter(10.0, string.Format("Connecting {0}", this));
            waiter.WaitFor(() => this.IsConnected);

            // Login
            this.Wait();
            this.Client.LogIn(this.UserName, this.RealName, this.NickName, this.HostName, null, this.Password);
            this.CommandSent();
        }
Exemple #2
0
 /// <summary>
 ///     The join.
 /// </summary>
 private void Join()
 {
     this.ServerUser.Wait();
     this.ServerUser.Client.Join(this.Name);
     this.ServerUser.CommandSent();
     var waiter = new Waiter(10.0, string.Format("Join {0}", this));
     waiter.WaitFor(() => this.IsActive);
 }
Exemple #3
0
 /// <summary>
 ///     The leave.
 /// </summary>
 public void Leave()
 {
     // Leave
     this.ServerUser.Wait();
     this.ServerUser.Client.Leave(this.Name);
     this.ServerUser.CommandSent();
     var waiter = new Waiter(10.0, string.Format("Leave {0}", this));
     waiter.WaitFor(() => !this.IsActive);
 }
Exemple #4
0
        /// <summary>
        /// The log out.
        /// </summary>
        public void LogOut()
        {
            if (!this.IsConnected)
            {
                return;
            }

            // Logout
            this.Wait();
            this.Client.LogOut(string.Format("{0} logging out.", this.NickName));

            // Close
            this.Client.Close();
            var waiter = new Waiter(10.0, string.Format("Leave {0}", this));
            waiter.WaitFor(() => !this.IsConnected);
        }