static void ReceviceSyncMsg(SyncSession session, T msg)
    {
        //Debug.Log("ReceviceSyncMsg " + msg.id + " content " +  Serializer.Serialize(msg));

        //消息确认
        AffirmMsg amsg = new AffirmMsg();

        amsg.index = msg.frame;
        amsg.time  = msg.time;
        ProtocolAnalysisService.SendMsg(session, amsg);

        ConnectionComponent connectComp = session.m_connect;

        if (connectComp != null)
        {
            WorldBase world = connectComp.Entity.World;

            if (msg.frame > world.FrameCount)
            {
                //广播这帧
                BroadcastCommand(world, connectComp, msg, false);
                connectComp.AddCommand(msg);
            }
            else
            {
                //当成最新的一帧来处理
                msg.frame = world.FrameCount;
                connectComp.AddCommand(msg);
            }

            ControlSpeed(connectComp, world, msg.frame);
        }
    }
    static void ReceviceSameCmdMsg(SyncSession session, SameCommand msg)
    {
        //消息确认
        AffirmMsg amsg = new AffirmMsg();

        amsg.index = msg.frame;
        amsg.time  = msg.time;
        ProtocolAnalysisService.SendMsg(session, amsg);

        ConnectionComponent connectComp = session.m_connect;

        if (connectComp != null)
        {
            WorldBase world = connectComp.Entity.World;

            //取上一帧的数据
            T scmd = (T)connectComp.GetCommand(msg.frame - 1).DeepCopy();

            if (msg.frame > world.FrameCount)
            {
                scmd.frame = msg.frame;

                connectComp.AddCommand(scmd);
                BroadcastSameCommand(world, connectComp, msg, true);
            }
            else
            {
                scmd.frame = world.FrameCount;
                connectComp.AddCommand(scmd);
            }

            ControlSpeed(connectComp, world, msg.frame);
        }
    }
예제 #3
0
    static void ReceviceSyncMsg(SyncSession session, T msg)
    {
        //Debug.Log("ReceviceSyncMsg " + msg.id + " content " +  Serializer.Serialize(msg));

        //消息确认
        AffirmMsg amsg = new AffirmMsg();

        amsg.index = msg.frame;
        amsg.time  = msg.time;
        ProtocolAnalysisService.SendMsg(session, amsg);

        ConnectionComponent connectComp = session.m_connect;

        if (connectComp != null)
        {
            WorldBase world = connectComp.Entity.World;

            if (world.FrameCount <= msg.frame + 4)
            {
                connectComp.AddCommand(msg);
            }

            //msg.frame = world.FrameCount + 1;

            //    //广播这帧
            //    if(connectComp.AddCommand(msg))
            //    {
            //        //BroadcastCommand(world, connectComp, msg, false);
            //    }
            //}
            //else
            //{
            //    //Debug.Log("丢弃掉 " + msg.frame);

            //    //直接丢弃掉落后帧

            //    //Debug.Log("帧相等! " + msg.frame);

            //    //if (!connectComp.m_isInframe)
            //    //{
            //    //    //当成最新的一帧来处理
            //    //    msg.frame = world.FrameCount + 1;
            //    //    connectComp.AddCommand(msg);
            //    //}
            //    //else
            //    //{
            //    //    Debug.Log("在一帧之内插入了数据! " + msg.frame);

            //    //    msg.frame = world.FrameCount + 1;
            //    //    connectComp.AddCommand(msg);
            //    //}
            //}

            ControlSpeed(connectComp, world, msg.frame);
        }
    }
예제 #4
0
    static void ReceviceSameCmdMsg(SyncSession session, SameCommand msg)
    {
        //消息确认
        AffirmMsg amsg = new AffirmMsg();

        amsg.index = msg.frame;
        amsg.time  = msg.time;
        ProtocolAnalysisService.SendMsg(session, amsg);

        ConnectionComponent connectComp = session.m_connect;

        if (connectComp != null)
        {
            WorldBase world = connectComp.Entity.World;

            if (world.FrameCount <= msg.frame + 4)
            {
                //取上一帧的数据
                T scmd = (T)connectComp.GetCommand(msg.frame - 1).DeepCopy();
                scmd.frame = world.FrameCount + 1;
                connectComp.AddCommand(scmd);
            }

            //    //取上一帧的数据
            //    T scmd = (T)connectComp.GetCommand(msg.frame - 1).DeepCopy();
            ////msg.frame = world.FrameCount + 1;
            //    scmd.frame = world.FrameCount + 1;
            //if (connectComp.AddCommand(scmd))
            //    {
            //        //BroadcastSameCommand(world, connectComp, msg, true);
            //    }
            //}
            //else
            //{
            //    //Debug.Log("Same frame " + world.FrameCount);
            //    //scmd.frame = world.FrameCount + 1;
            //    //connectComp.AddCommand(scmd);
            //}

            ControlSpeed(connectComp, world, msg.frame);
        }
    }