コード例 #1
0
        /// <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;
        }
コード例 #2
0
ファイル: IrcChannel.cs プロジェクト: JustOxlamon/TwoRatChat
        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));
        }
コード例 #3
0
ファイル: IrcChannel.cs プロジェクト: JustOxlamon/TwoRatChat
        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);
        }
コード例 #4
0
        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;
            }
        }
コード例 #5
0
ファイル: IrcChannel.cs プロジェクト: JustOxlamon/TwoRatChat
 internal void HandleUserQuit(IrcChannelUser channelUser)
 {
     lock (((ICollection)this.usersReadOnly).SyncRoot)
         this.users.Remove(channelUser);
 }
コード例 #6
0
        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;
        }
コード例 #7
0
ファイル: IrcEventArgs.cs プロジェクト: ByteSempai/Ubiquitous
        /// <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;
        }
コード例 #8
0
ファイル: IrcChannel.cs プロジェクト: ByteSempai/Ubiquitous
 internal void HandleUserQuit(IrcChannelUser channelUser)
 {
     lock (((ICollection)this.usersReadOnly).SyncRoot)
         this.users.Remove(channelUser);
 }
コード例 #9
0
ファイル: IrcChannel.cs プロジェクト: ByteSempai/Ubiquitous
        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));
        }
コード例 #10
0
ファイル: IrcChannel.cs プロジェクト: ByteSempai/Ubiquitous
        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));
        }