/// <inheritdoc/>
        /// <summary>
        /// Initializes a new instance of the <see cref="IrcChannelUserEventArgs"/> class.
        /// </summary>
        /// <param name="channelUser">The channel user that the event concerns.</param>
        public IrcChannelUserEventArgs(IrcChannelUser channelUser, string comment = null)
            : base(comment)
        {
            if (channelUser == null)
            {
                throw new ArgumentNullException("channelUser");
            }

            this.ChannelUser = channelUser;
        }
Exemple #2
0
        internal void HandleUserKicked(IrcChannelUser channelUser, string comment)
        {
            lock (((ICollection)this.usersReadOnly).SyncRoot)
            {
                if (channelUser == null)
                {
                    return;
                }

                this.users.Remove(channelUser);
            }

            OnUserKicked(new IrcChannelUserEventArgs(channelUser, comment));
        }
Exemple #3
0
        internal void HandleUserNameReply(IrcChannelUser channelUser)
        {
            lock (((ICollection)this.modesReadOnly).SyncRoot)
            {
                if (this.users.Contains(channelUser))
                {
#if SILVERLIGHT
                    Debug.Assert(false, "User already in channel.");
#else
                    Debug.Fail("User already in channel.");
#endif
                    return;
                }
            }

            channelUser.Channel = this;
            lock (((ICollection)this.usersReadOnly).SyncRoot)
                this.users.Add(channelUser);
        }
        protected void ProcessMessageReplyWhoReply(IrcMessage message)
        {
            //Debug.Assert(message.Parameters[0] == this.localUser.NickName);

            Debug.Assert(message.Parameters[1] != null);
            var channel = message.Parameters[1] == "*" ? null : GetChannelFromName(message.Parameters[1]);

            Debug.Assert(message.Parameters[5] != null);
            var user = GetUserFromNickName(message.Parameters[5]);

            Debug.Assert(message.Parameters[2] != null);
            var userName = message.Parameters[2];

            Debug.Assert(message.Parameters[3] != null);
            user.HostName = message.Parameters[3];
            Debug.Assert(message.Parameters[4] != null);
            user.ServerName = message.Parameters[4];

            Debug.Assert(message.Parameters[6] != null);
            var userModeFlags = message.Parameters[6];

            Debug.Assert(userModeFlags.Length > 0);
            if (userModeFlags.Contains('H'))
            {
                user.IsAway = false;
            }
            else if (userModeFlags.Contains('G'))
            {
                user.IsAway = true;
            }
            user.IsOperator = userModeFlags.Contains('*');
            if (channel != null)
            {
                // Add user to channel if it does not already exist in it.
                var channelUser = channel.GetChannelUser(user);
                if (channelUser == null)
                {
                    channelUser = new IrcChannelUser(user);
                    channel.HandleUserJoined(channelUser);
                }

                // Set modes on user corresponding to given mode flags (prefix characters).
                foreach (var c in userModeFlags)
                {
                    char mode;
                    if (this.channelUserModesPrefixes.TryGetValue(c, out mode))
                    {
                        channelUser.HandleModeChanged(true, mode);
                    }
                    else
                    {
                        break;
                    }
                }
            }

            Debug.Assert(message.Parameters[7] != null);
            var lastParamParts = message.Parameters[7].SplitIntoPair(" ");

            user.HopCount = int.Parse(lastParamParts.Item1);
            if (lastParamParts.Item2 != null)
            {
                user.RealName = lastParamParts.Item2;
            }
        }
Exemple #5
0
 internal void HandleUserQuit(IrcChannelUser channelUser)
 {
     lock (((ICollection)this.usersReadOnly).SyncRoot)
         this.users.Remove(channelUser);
 }
        protected void ProcessMessageReplyWhoReply(IrcMessage message)
        {
            Debug.Assert(message.Parameters[0] == this.localUser.NickName);

            Debug.Assert(message.Parameters[1] != null);
            var channel = message.Parameters[1] == "*" ? null : GetChannelFromName(message.Parameters[1]);

            Debug.Assert(message.Parameters[5] != null);
            var user = GetUserFromNickName(message.Parameters[5]);

            Debug.Assert(message.Parameters[2] != null);
            var userName = message.Parameters[2];
            Debug.Assert(message.Parameters[3] != null);
            user.HostName = message.Parameters[3];
            Debug.Assert(message.Parameters[4] != null);
            user.ServerName = message.Parameters[4];

            Debug.Assert(message.Parameters[6] != null);
            var userModeFlags = message.Parameters[6];
            Debug.Assert(userModeFlags.Length > 0);
            if (userModeFlags.Contains('H'))
                user.IsAway = false;
            else if (userModeFlags.Contains('G'))
                user.IsAway = true;
            user.IsOperator = userModeFlags.Contains('*');
            if (channel != null)
            {
                // Add user to channel if it does not already exist in it.
                var channelUser = channel.GetChannelUser(user);
                if (channelUser == null)
                {
                    channelUser = new IrcChannelUser(user);
                    channel.HandleUserJoined(channelUser);
                }

                // Set modes on user corresponding to given mode flags (prefix characters).
                foreach (var c in userModeFlags)
                {
                    char mode;
                    if (this.channelUserModesPrefixes.TryGetValue(c, out mode))
                        channelUser.HandleModeChanged(true, mode);
                    else
                        break;
                }
            }

            Debug.Assert(message.Parameters[7] != null);
            var lastParamParts = message.Parameters[7].SplitIntoPair(" ");
            user.HopCount = int.Parse(lastParamParts.Item1);
            if (lastParamParts.Item2 != null)
                user.RealName = lastParamParts.Item2;
        }
        /// <inheritdoc/>
        /// <summary>
        /// Initializes a new instance of the <see cref="IrcChannelUserEventArgs"/> class.
        /// </summary>
        /// <param name="channelUser">The channel user that the event concerns.</param>
        public IrcChannelUserEventArgs(IrcChannelUser channelUser, string comment = null)
            : base(comment)
        {
            if (channelUser == null)
                throw new ArgumentNullException("channelUser");

            this.ChannelUser = channelUser;
        }
Exemple #8
0
 internal void HandleUserQuit(IrcChannelUser channelUser)
 {
     lock (((ICollection)this.usersReadOnly).SyncRoot)
         this.users.Remove(channelUser);
 }
Exemple #9
0
        internal void HandleUserKicked(IrcChannelUser channelUser, string comment)
        {
            lock (((ICollection)this.usersReadOnly).SyncRoot)
            {
                if (channelUser == null)
                    return;

                this.users.Remove(channelUser);
            }

            OnUserKicked(new IrcChannelUserEventArgs(channelUser, comment));
        }
Exemple #10
0
        internal void HandleUserJoined(IrcChannelUser channelUser)
        {
            lock (((ICollection)this.modesReadOnly).SyncRoot)
            {
                if (this.users.Contains(channelUser))
                {
#if SILVERLIGHT
                Debug.Assert(false, "User already in channel.");
#else
                    Debug.Fail("User already in channel.");
#endif
                    return;
                }
            }

            channelUser.Channel = this;
            lock (((ICollection)this.usersReadOnly).SyncRoot)
                this.users.Add(channelUser);

            OnUserJoined(new IrcChannelUserEventArgs(channelUser, null));
        }