Beispiel #1
0
        /// <summary>
        /// ping网络
        /// </summary>
        private void OnPingNet(PacketBase packet)
        {
            c2ss.PingNet msg = packet as c2ss.PingNet;

            if (Utils.HasFlag(msg.flags, (uint)eServerType.GLOBAL))
            {//ping gl
                ss2gl.PingNet rep_msg = PacketPools.Get(ss2gl.msg.PING_NET) as ss2gl.PingNet;
                rep_msg.client_uid = msg.client_uid;
                rep_msg.packet_id  = msg.packet_id;
                rep_msg.tick       = msg.tick;
                rep_msg.flags      = msg.flags;
                ServerNetManager.Instance.Send2GL(rep_msg);
            }
            else
            {
                long offset_time = Time.time - msg.tick;
                Log.Debug("收到第:" + msg.packet_id + " 时间:" + Time.time + " 延迟:" + offset_time);

                ss2c.PingNet rep_msg = PacketPools.Get(ss2c.msg.PING_NET) as ss2c.PingNet;
                rep_msg.packet_id = msg.packet_id;
                rep_msg.tick      = msg.tick;
                rep_msg.flags     = msg.flags;
                ServerNetManager.Instance.SendProxy(msg.client_uid, rep_msg);
            }
        }
        private void OnPingNet(PacketBase packet)
        {
            eServerType server_type = eServerType.NONE;
            uint        packet_id   = 0; //发送包id
            long        tick        = 0; //发送时间,记录延迟
            long        offset_time = 0;
            uint        flags       = 0;

            if (packet is gs2c.PingNet)
            {
                gs2c.PingNet msg = packet as gs2c.PingNet;
                server_type = eServerType.GATE;
                packet_id   = msg.packet_id;
                tick        = msg.tick;
                offset_time = Time.time - tick;
                flags       = msg.flags;
                Log.Debug("收到gs包:" + msg.packet_id + " 时间:" + Time.time + " 延迟:" + (Time.time - msg.tick));
            }
            else if (packet is ss2c.PingNet)
            {
                ss2c.PingNet msg = packet as ss2c.PingNet;
                packet_id   = msg.packet_id;
                tick        = msg.tick;
                offset_time = Time.time - tick;
                flags       = msg.flags;
                if (Utils.HasFlag(msg.flags, (uint)eServerType.GLOBAL))
                {
                    server_type = eServerType.GLOBAL;
                }
                else
                {
                    server_type = eServerType.SERVER;
                }
                Log.Debug("收到ss包:" + msg.packet_id + " 时间:" + Time.time + " 延迟:" + (Time.time - msg.tick));
            }
            else if (packet is fs2c.PingNet)
            {
                fs2c.PingNet msg = packet as fs2c.PingNet;
                server_type = eServerType.FIGHT;
                packet_id   = msg.packet_id;
                tick        = msg.tick;
                offset_time = Time.time - tick;
                flags       = msg.flags;
                Log.Debug("收到fs包:" + msg.packet_id + " 时间:" + Time.time + " 延迟:" + (Time.time - msg.tick));
            }
            else if (packet is ws2c.PingNet)
            {
                ws2c.PingNet msg = packet as ws2c.PingNet;
                server_type = eServerType.WORLD;
                packet_id   = msg.packet_id;
                tick        = msg.tick;
                offset_time = Time.time - tick;
                flags       = msg.flags;
                Log.Debug("收到ws包:" + msg.packet_id + " 时间:" + Time.time + " 延迟:" + (Time.time - msg.tick));
            }
            if (server_type != eServerType.NONE)
            {
                EventController.TriggerEvent(ClientEventID.SERVER_PING, server_type, packet_id, tick, offset_time, flags);
            }
        }
Beispiel #3
0
        /// <summary>
        /// ping网络
        /// </summary>
        private void OnPingNet(PacketBase packet)
        {
            gl2ss.PingNet msg = packet as gl2ss.PingNet;

            ss2c.PingNet rep_msg = PacketPools.Get(ss2c.msg.PING_NET) as ss2c.PingNet;
            rep_msg.packet_id = msg.packet_id;
            rep_msg.tick      = msg.tick;
            rep_msg.flags     = msg.flags;
            ServerNetManager.Instance.SendProxy(msg.client_uid, rep_msg);
        }