Beispiel #1
0
        //踢掉(管理场景)
        public async Task KickClient(KickClient args)
        {
            this.FixScopeIdForContext().FixScopeIdForArgs(args);
            TraceHubContext("KickClient");

            await _hubEventBus.Raise(new KickClientEvent(this, args)).ConfigureAwait(false);

            await base.OnConnectedAsync().ConfigureAwait(false);
        }
        private void HandlerKickClient(KickClient kickClient)
        {
            ExchangeClient client = endpoint as ExchangeClient;

            client.Kick(kickClient.Reason);
        }
        public object Decode(Remoting.Channel ch, Packet packet)
        {
            BinaryDataInput input = new BinaryDataInput(packet.Content);
            int             type  = packet.Header.Type;

            if (type == Packet.FLAG_HANDSNAKE)
            {
                HandSnakeResp resp = new HandSnakeResp();
                resp.DeserializeTo(input);
                return(resp);
            }
            else if (type == Packet.FLAG_HEARTBEAT)
            {
                HeartBeatResp req = new HeartBeatResp();
                req.DeserializeTo(input);
                return(req);
            }
            else if (type == Packet.FLAG_KICK)
            {
                KickClient kick = new KickClient();
                kick.DeserializeTo(input);
                return(kick);
            }
            else if (type == Packet.FLAG_MESSAGE)
            {
                int  mid   = input.ReadInt();
                byte mType = input.ReadByte();
                if (mType == AbstractMessage.TYPE_RESPONSE)
                {
                    Response response = new Response(mid);
                    response.Sequence  = input.ReadInt();
                    response.ErrorCode = input.ReadInt();
                    response.ErrorDes  = input.ReadUTF();
                    if (response.ErrorCode == Response.OK)
                    {
                        ResponseArg respArg = ResponseMappingInfo.Instance.CreateResponseMapping(mid) as ResponseArg;
                        if (respArg == null)
                        {
                            log.Error("Failed to handle response message,Cause : Cloud not found response mapper id :" + mid);
                        }
                        respArg.DeserializeTo(input);
                        response.Content = respArg;
                    }
                    return(response);
                }
                else if (mType == AbstractMessage.TYPE_PUSH)
                {
                    Push push = new Push(mid);
                    push.Identity = input.ReadInt();
                    ResponseArg respArg = ResponseMappingInfo.Instance.CreateResponseMapping(mid) as ResponseArg;
                    if (respArg == null)
                    {
                        log.Error("Failed to handle push message,Cause : Cloud not found response mapper id :" + mid);
                    }
                    respArg.DeserializeTo(input);
                    push.Content = respArg;
                    return(push);
                }
                else if (mType == AbstractMessage.TYPE_BROADCAST)
                {
                    BroadCast broadcast = new BroadCast(mid);
                    broadcast.Identity = input.ReadInt();
                    ResponseArg respArg = ResponseMappingInfo.Instance.CreateResponseMapping(mid) as ResponseArg;
                    if (respArg == null)
                    {
                        log.Error("Failed to handle broadcast message,Cause : Cloud not found response mapper id :" + mid);
                    }
                    respArg.DeserializeTo(input);
                    broadcast.Content = respArg;
                    return(broadcast);
                }
            }
            return(null);
        }