Ejemplo n.º 1
0
        static void OnHandSnake(MyEvent arg)
        {
            UnityClientEvent evt  = arg as UnityClientEvent;
            HandSnakeResp    resp = evt.GetParame <HandSnakeResp>();

            client.Logger.Info("OnHandSnake =>> success:" + evt.Success + ",parame :" + resp);
        }
Ejemplo n.º 2
0
        static void OnChannelDataError(MyEvent arg)
        {
            UnityClientEvent evt  = arg as UnityClientEvent;
            HandSnakeResp    resp = evt.GetParame <HandSnakeResp>();

            Console.WriteLine("OnHandSnake:" + resp.GetType().FullName);
        }
Ejemplo n.º 3
0
        static void OnConnectResum(MyEvent arg)
        {
            UnityClientEvent evt  = arg as UnityClientEvent;
            HandSnakeResp    resp = evt.GetParame <HandSnakeResp>();

            Console.WriteLine("OnConnectResum:" + resp.GetType().FullName);
        }
Ejemplo n.º 4
0
        private void HandlHandSnake(MyEvent evt)
        {
            UnityClientEvent ucEvt = evt as UnityClientEvent;

            if (evt.Success)
            {
                HandSnakeResp resp = evt.GetParame <HandSnakeResp>();
                this.sessionToken = resp.ReconnectToken;

                if (this.debug)
                {
                    string[] messages = new string[] { string.Format("Handshake response: sessionToken => {0}, heartbeatTime => {1}", this.sessionToken, resp.HeartbeatTime) };
                    this.log.Debug(messages);
                }

                if (this.client.IsReconnecting)
                {
                    this.client.IsReconnecting = false;
                    this.Dispatch(new UnityClientEvent(UnityClientEvent.CONNECTION_RESUME));
                }
                else
                {
                    this.isConnecting = false;
                    this.Dispatch(new UnityClientEvent(UnityClientEvent.CONNECTION));
                }
            }
            else
            {
                UnityClientEvent cEvt = new UnityClientEvent(UnityClientEvent.CONNECTION);
                cEvt.Success  = false;
                cEvt.ErrorDes = "Failed to HandSnake";
                this.Dispatch(cEvt);
            }
        }
Ejemplo n.º 5
0
        public void HandlerHandSnake(HandSnakeResp resp)
        {
            this.heatbeatTime = resp.HeartbeatTime;
            this.payload      = resp.Payload;
            if (heatbeatService == null)
            {
                heatbeatService = new HeartBeatService(this, heatbeatTime);
            }
            //heatbeatService.Start();
            UnityClientEvent evt = new UnityClientEvent(UnityClientEvent.HANDSHAKE);

            evt.Success = resp.Success;
            evt.Parame  = resp;
            parent.Dispatch(evt);
        }
        private void HandlerHandSnakeResp(HandSnakeResp resp)
        {
            ExchangeClient client = endpoint as ExchangeClient;

            client.HandlerHandSnake(resp);
        }
Ejemplo n.º 7
0
        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);
        }