Ejemplo n.º 1
0
        protected override void CheckRequest()
        {
            switch (_request.RequestType)
            {
            case ChatMessageType.ChannelMessage:
                base.CheckRequest();
                break;

            case ChatMessageType.UserMessage:

                if (_request.RequestType == ChatMessageType.UserMessage)
                {
                    if (!ChatSessionManager.GetSessionByNickName(_request.NickName, out _otherSession))
                    {
                        _errorCode     = ChatError.NoSuchNick;
                        _sendingBuffer = ChatIRCError.BuildNoSuchNickError();
                    }
                }
                break;

            default:
                _errorCode = ChatError.Parse;
                break;
            }
        }
Ejemplo n.º 2
0
        public override void CheckRequest()
        {
            base.CheckRequest();

            if (_errorCode != ChatError.NoError)
            {
                return;
            }

            if (_session.UserInfo.JoinedChannels.Count == 0)
            {
                _errorCode     = ChatError.IRCError;
                _sendingBuffer = ChatIRCError.BuildNoSuchChannelError(_cmd.ChannelName);
                return;
            }

            if (!_session.UserInfo.GetJoinedChannelByName(_cmd.ChannelName, out _channel))
            {
                _errorCode     = ChatError.IRCError;
                _sendingBuffer = ChatIRCError.BuildNoSuchChannelError(_cmd.ChannelName);
                return;
            }

            if (!_channel.GetChannelUserBySession(_session, out _user))
            {
                _errorCode     = ChatError.Parse;
                _sendingBuffer = ChatIRCError.BuildNoSuchNickError();
                return;
            }
        }
Ejemplo n.º 3
0
        public override void CheckRequest()
        {
            base.CheckRequest();

            if (ChatSessionManager.IsNickNameExisted(_cmd.NickName))
            {
                _errorCode     = ChatError.IRCError;
                _sendingBuffer = ChatIRCError.BuildNoSuchNickError();
            }
        }
Ejemplo n.º 4
0
        protected override void BuildErrorResponse()
        {
            base.BuildErrorResponse();
            switch (_errorCode)
            {
            case ChatError.NoSuchChannel:
                _sendingBuffer =
                    ChatIRCError.BuildNoSuchChannelError(_request.ChannelName);
                break;

            case ChatError.NoSuchNick:
                _sendingBuffer = ChatIRCError.BuildNoSuchNickError();
                break;
            }
        }
Ejemplo n.º 5
0
 public override void CheckRequest()
 {
     base.CheckRequest();
     //can not find any user
     if (!_channel.GetChannelUserBySession(_session, out _user))
     {
         _errorCode     = ChatError.IRCError;
         _sendingBuffer = ChatIRCError.BuildNoSuchNickError();
         return;
     }
     if (!ChatChannelManager.GetChannel(_cmd.ChannelName, out _channel))
     {
         _errorCode     = ChatError.IRCError;
         _sendingBuffer = ChatIRCError.BuildNoSuchChannelError(_cmd.ChannelName);
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Send all channel user information
        /// </summary>
        private void GetUserInfo()
        {
            ChatSession session;

            if (ChatSessionManager.GetSessionByNickName(_cmd.Name, out session))
            {
                BuildWhoReplyForUser(session);
            }
            else if (ChatSessionManager.GetSessionByUserName(_cmd.Name, out session))
            {
                BuildWhoReplyForUser(session);
            }
            else //todo check whether we need this error
            {
                _errorCode     = ChatError.IRCError;
                _sendingBuffer = ChatIRCError.BuildNoSuchNickError();
            }
        }
Ejemplo n.º 7
0
        protected override void CheckRequest()
        {
            base.CheckRequest();

            if (_request.NickName != _session.UserInfo.NickName)
            {
                if (!_user.IsChannelOperator)
                {
                    _errorCode = ChatError.NotChannelOperator;
                    return;
                }
                IsSetOthersKeyValue = true;
                if (!_channel.GetChannelUserByNickName(_request.NickName, out _otherUser))
                {
                    _errorCode     = ChatError.IRCError;
                    _sendingBuffer = ChatIRCError.BuildNoSuchNickError();
                    return;
                }
            }
        }
Ejemplo n.º 8
0
        public override void CheckRequest()
        {
            base.CheckRequest();
            if (_errorCode != Entity.Structure.ChatError.NoError)
            {
                return;
            }

            var result = from s in ChatSessionManager.Sessions.Values
                         where s.UserInfo.NickName == _cmd.NickName
                         select s.UserInfo;

            if (result.Count() != 1)
            {
                _errorCode     = Entity.Structure.ChatError.IRCError;
                _sendingBuffer = ChatIRCError.BuildNoSuchNickError();
                return;
            }
            _userInfo = result.FirstOrDefault();
        }
Ejemplo n.º 9
0
        private void GetChannelAndUser()
        {
            if (_session.UserInfo.JoinedChannels.Count == 0)
            {
                _errorCode     = ChatError.IRCError;
                _sendingBuffer = ChatIRCError.BuildNoSuchChannelError(_cmd.ChannelName);
                return;
            }

            if (!_session.UserInfo.GetJoinedChannelByName(_cmd.ChannelName, out _channel))
            {
                _errorCode     = ChatError.IRCError;
                _sendingBuffer = ChatIRCError.BuildNoSuchChannelError(_cmd.ChannelName);
                return;
            }

            if (!_channel.GetChannelUserBySession(_session, out _user))
            {
                _errorCode     = ChatError.Parse;
                _sendingBuffer = ChatIRCError.BuildNoSuchNickError();
                return;
            }
        }
Ejemplo n.º 10
0
 protected override void BuildErrorResponse()
 {
     base.BuildErrorResponse();
     _sendingBuffer = ChatIRCError.BuildNoSuchNickError();
 }