Exemplo n.º 1
0
        public void Tick()
        {
            FileDataBuff buff = PopRecvData();

            while (buff != null)
            {
                if (!Invoke(buff))
                {
                    LogManager.Debug("TcpSession::Tick => invoke error");
                    Stop();
                    return;
                }
                buff.Clear();
                buff = PopRecvData();
            }
        }
Exemplo n.º 2
0
        protected bool Invoke(FileDataBuff buff)
        {
            if (buff == null || _rpcCallbackArray == null)
            {
                return(false);
            }

            if (buff._dataLen < 4)
            {
                return(false);
            }

            uint readLen = 0;
            uint msgType = 0;
            uint msgLen  = 0;

            byte[] ushortBytes = new byte[2];

            readLen = 2;
            SerializeUtil.LEMemcpy(ushortBytes, 0, buff._data, buff.GetReadPos(), readLen);
            buff._readPos += readLen;
            msgType        = BitConverter.ToUInt16(ushortBytes, 0);

            if (msgType >= _rpcCallbackNum)
            {
                return(false);
            }

            readLen = 2;
            SerializeUtil.LEMemcpy(ushortBytes, 0, buff._data, buff.GetReadPos(), readLen);
            buff._readPos += readLen;
            msgLen         = BitConverter.ToUInt16(ushortBytes, 0);

            if (buff.GetUnreadLen() != msgLen)
            {
                return(false);
            }

            return(_rpcCallbackArray[msgType](buff._data, buff.GetReadPos(), msgLen));
        }