/// <summary>
 /// 检测客户端是登陆/活跃
 /// </summary>
 /// <param name="command"></param>
 /// <returns></returns>
 public bool CheckLogined(ControlSocketCommand command)
 {
     if ((command == ControlSocketCommand.Login) | (command == ControlSocketCommand.Active))
         return true;
     else
         return m_logined;
 }
예제 #2
0
        public override bool ProcessCommand(byte[] buffer, int offset, int count) //处理分完包的数据,子类从这个方法继承
        {
            ControlSocketCommand command = StrToCommand(m_incomingDataParser.Command);

            m_outgoingDataAssembler.Clear();
            m_outgoingDataAssembler.AddResponse();
            m_outgoingDataAssembler.AddCommand(m_incomingDataParser.Command);
            if (!CheckLogined(command)) //检测登录
            {
                m_outgoingDataAssembler.AddFailure(ProtocolCode.UserHasLogined, "");
                return(DoSendResult());
            }
            if (command == ControlSocketCommand.Login)
            {
                return(DoLogin());
            }
            else if (command == ControlSocketCommand.Active)
            {
                return(DoActive());
            }
            else if (command == ControlSocketCommand.GetClients)
            {
                return(DoGetClients());
            }
            else
            {
                return(false);
            }
        }
예제 #3
0
        /// <summary>
        /// 处理分完包的数据,
        /// </summary>
        /// <param name="buffer"></param>
        /// <param name="offset"></param>
        /// <param name="count"></param>
        /// <returns></returns>
        public override bool ProcessCommand(byte[] buffer, int offset, int count)
        {
            ControlSocketCommand command = StrToCommand(m_incomingDataParser.Command);

            m_outgoingDataAssembler.Clear();
            m_outgoingDataAssembler.AddResponse();
            m_outgoingDataAssembler.AddCommand(m_incomingDataParser.Command);
            if (!CheckLogined(command)) //检测登录
            {
                m_outgoingDataAssembler.AddFailure(ProtocolCode.UserHasLogined, "");
                return(DoSendResult());
            }
            if (command == ControlSocketCommand.Login)
            {
                return(DoLogin());
            }
            else if (command == ControlSocketCommand.Active)
            {
                return(DoActive());
            }
            else
            {
                Program.Logger.Error("Unknow command: " + m_incomingDataParser.Command);
                return(false);
            }
        }
예제 #4
0
 public bool CheckLogined(ControlSocketCommand command)
 {
     if ((command == ControlSocketCommand.Login) | (command == ControlSocketCommand.Active))
     {
         return(true);
     }
     else
     {
         return(m_logined);
     }
 }
예제 #5
0
        //需要响应
        public override bool ProcessCommand(byte[] buffer, int offset, int count) //处理分完包的数据,子类从这个方法继承
        {
            ControlSocketCommand command = StrToCommand(m_incomingDataParser.Command);

            m_outgoingDataAssembler.Clear();
            m_outgoingDataAssembler.AddResponse();
            m_outgoingDataAssembler.AddCommand(m_incomingDataParser.Command);
//             if (!CheckLogined(command)) //检测登录
//             {
//                 m_outgoingDataAssembler.AddFailure(ProtocolCode.UserHasLogined, "");
//                 return DoSendResult();
//             }
            if (command == ControlSocketCommand.Login)
            {
                return(DoLogin());
            }
            else if (command == ControlSocketCommand.Active)
            {
                return(DoActive());
            }
            else if (command == ControlSocketCommand.GetClients)
            {
                return(DoGetClients());
            }
            else if (command == ControlSocketCommand.HeartBeat)//心跳包响应
            {
                return(DoHeartBeat());
            }
            else if (command == ControlSocketCommand.DataReceive)//数接收
            {
                return(true);
            }
            else
            {
                Program.Logger.Error("Unknow command: " + m_incomingDataParser.Command);

                Console.WriteLine("Unknow command: " + m_incomingDataParser.Command);
                return(false);
            }
        }