Пример #1
0
        private void _serverSokcet_OnReceive(object userToken, byte[] data)
        {
            if (IsDebug)
            {
                LogHelper.Debug(userToken == null ? "userToken is null" : "userToken is not null");
                LogHelper.Debug(data);
            }

            var ut = (IUserToken)userToken;

            try
            {
                if (ut == null)
                {
                    throw new KernelException("userToken is null");
                }

                HUnpacker unpacker = (HUnpacker)ut.Unpacker;

                unpacker.GetRequest(data, (result) =>
                {
                    OnRequested?.Invoke(ut, result);
                });
            }
            catch (Exception ex)
            {
                LogHelper.Error("Http解码出现异常", ex);
                Disconnecte(ut);
            }
        }
Пример #2
0
        protected override void OnReceiveBytes(IUserToken userToken, byte[] data)
        {
            HUnpacker unpacker = (HUnpacker)userToken.Unpacker;

            unpacker.GetRequest(data, (result) =>
            {
                OnRequested?.Invoke(userToken, result);
            });
        }
Пример #3
0
        private void _serverSokcet_OnReceive(string id, byte[] data)
        {
            var userToken = ((IocpServerSocket)_serverSokcet).SessionManager.Get(id);

            HUnpacker unpacker = (HUnpacker)userToken.Unpacker;

            unpacker.GetRequest(data, (result) =>
            {
                OnRequested?.Invoke(userToken, result);
            });
        }
Пример #4
0
        private void _serverSokcet_OnReceive(object userToken, byte[] data)
        {
            var ut = (IUserToken)userToken;

            try
            {
                HUnpacker unpacker = (HUnpacker)ut.Unpacker;

                unpacker.GetRequest(ut.ID, data, (result) =>
                {
                    OnRequested?.Invoke(ut, result);
                });
            }
            catch (Exception ex)
            {
                LogHelper.Error("Http解码出现异常", ex);
                Disconnecte(ut);
            }
        }