public static void AnalysisAndDispatchMessage(SyncSession session, ProtocolRequestBase cmd)
    {
        switch (cmd.Key)
        {
        case  "changecomponentmsg": ReceviceChangeComponentMsg(session, cmd); break;

        case  "changesingletoncomponentmsg": ReceviceChangeSingletonComponentMsg(session, cmd); break;

        case  "debugmsg": ReceviceDebugMsg(session, cmd); break;

        case  "destroyentitymsg": ReceviceDestroyEntityMsg(session, cmd); break;

        case  "pursuemsg": RecevicePursueMsg(session, cmd); break;

        case  "startsyncmsg": ReceviceStartSyncMsg(session, cmd); break;

        case  "syncentitymsg": ReceviceSyncEntityMsg(session, cmd); break;

        case  "commandcomponent": ReceviceCommandComponent(session, cmd); break;

        default:
            Debug.LogError("Recevice Exception : 不支持的消息类型!" + cmd.Key);
            break;
        }
    }
    static void ReceviceDebugMsg(SyncSession session, ProtocolRequestBase e)
    {
        Protocol.DebugMsg msg = new Protocol.DebugMsg();
        msg.frame = (int)e.m_data["frame"];
        {
            List <Dictionary <string, object> > data2 = (List <Dictionary <string, object> >)e.m_data["infos"];
            List <Protocol.EntityInfo>          list2 = new List <Protocol.EntityInfo>();
            for (int i2 = 0; i2 < data2.Count; i2++)
            {
                Protocol.EntityInfo tmp2 = new Protocol.EntityInfo();
                tmp2.id = (int)data2[i2]["id"];
                {
                    List <Dictionary <string, object> > data4 = (List <Dictionary <string, object> >)data2[i2]["infos"];
                    List <Protocol.ComponentInfo>       list4 = new List <Protocol.ComponentInfo>();
                    for (int i4 = 0; i4 < data4.Count; i4++)
                    {
                        Protocol.ComponentInfo tmp4 = new Protocol.ComponentInfo();
                        tmp4.m_compName = data4[i4]["m_compname"].ToString();
                        tmp4.content    = data4[i4]["content"].ToString();
                        list4.Add(tmp4);
                    }
                    tmp2.infos = list4;
                }
                list2.Add(tmp2);
            }
            msg.infos = list2;
        }

        EventService.DispatchTypeEvent(session, msg);
    }
    static void ReceviceCommandComponent(SyncSession session, ProtocolRequestBase e)
    {
        CommandComponent msg = new CommandComponent();

        {
            Dictionary <string, object> data2 = (Dictionary <string, object>)e.m_data["movedir"];
            SyncVector3 tmp2 = new SyncVector3();
            tmp2.x      = (int)data2["x"];
            tmp2.y      = (int)data2["y"];
            tmp2.z      = (int)data2["z"];
            msg.moveDir = tmp2;
        }
        {
            Dictionary <string, object> data2 = (Dictionary <string, object>)e.m_data["skilldir"];
            SyncVector3 tmp2 = new SyncVector3();
            tmp2.x       = (int)data2["x"];
            tmp2.y       = (int)data2["y"];
            tmp2.z       = (int)data2["z"];
            msg.skillDir = tmp2;
        }
        msg.isFire = (bool)e.m_data["isfire"];
        msg.id     = (int)e.m_data["id"];
        msg.frame  = (int)e.m_data["frame"];

        EventService.DispatchTypeEvent(session, msg);
    }
    static void RecevicePlayerLoginMsg_s(SyncSession session, ProtocolRequestBase e)
    {
        PlayerLoginMsg_s msg = new PlayerLoginMsg_s();

        msg.playerID = e.m_data["playerid"].ToString();

        EventService.DispatchTypeEvent(session, msg);
    }
    static void ReceviceAffirmMsg(SyncSession session, ProtocolRequestBase e)
    {
        Protocol.AffirmMsg msg = new Protocol.AffirmMsg();
        msg.frame = (int)e.m_data["frame"];
        msg.time  = (int)e.m_data["time"];

        EventService.DispatchTypeEvent(session, msg);
    }
Exemplo n.º 6
0
    static void RecevicePlayerRename_s(SyncSession session, ProtocolRequestBase e)
    {
        PlayerRename_s msg = new PlayerRename_s();

        msg.newName = e.m_data["newname"].ToString();

        EventService.DispatchTypeEvent(session, msg);
    }
Exemplo n.º 7
0
    static void ReceviceQueryCommand(SyncSession session, ProtocolRequestBase e)
    {
        Protocol.QueryCommand msg = new Protocol.QueryCommand();
        msg.frame = (int)e.m_data["frame"];
        msg.id    = (int)e.m_data["id"];

        EventService.DispatchTypeEvent(session, msg);
    }
    static void RecevicePlayerMatchMsg_s(SyncSession session, ProtocolRequestBase e)
    {
        PlayerMatchMsg_s msg = new PlayerMatchMsg_s();

        msg.isCancel = (bool)e.m_data["iscancel"];

        EventService.DispatchTypeEvent(session, msg);
    }
    static void RecevicePlayerSelectCharacter_s(SyncSession session, ProtocolRequestBase e)
    {
        PlayerSelectCharacter_s msg = new PlayerSelectCharacter_s();

        msg.characterID = e.m_data["characterid"].ToString();

        EventService.DispatchTypeEvent(session, msg);
    }
    static void ReceviceStartSyncMsg(SyncSession session, ProtocolRequestBase e)
    {
        Protocol.StartSyncMsg msg = new Protocol.StartSyncMsg();
        msg.frame        = (int)e.m_data["frame"];
        msg.intervalTime = (int)e.m_data["intervaltime"];

        EventService.DispatchTypeEvent(session, msg);
    }
    static void ReceviceDestroyEntityMsg(SyncSession session, ProtocolRequestBase e)
    {
        Protocol.DestroyEntityMsg msg = new Protocol.DestroyEntityMsg();
        msg.frame = (int)e.m_data["frame"];
        msg.id    = (int)e.m_data["id"];

        EventService.DispatchTypeEvent(session, msg);
    }
    static void RecevicePursueMsg(SyncSession session, ProtocolRequestBase e)
    {
        Protocol.PursueMsg msg = new Protocol.PursueMsg();
        msg.frame        = (int)e.m_data["frame"];
        msg.advanceCount = (int)e.m_data["advancecount"];

        EventService.DispatchTypeEvent(session, msg);
    }
        public static void Send(this SyncSession session, ProtocolRequestBase msg)
        {
            ByteArray ba = new ByteArray();

            ba.bytes.AddRange(GetSendByte(msg.Key, msg.m_data));

            byte[] buffer = ba.Buffer;

            session.Send(buffer, 0, buffer.Length);
        }
    static void ReceviceStartSyncMsg(SyncSession session, ProtocolRequestBase e)
    {
        Protocol.StartSyncMsg msg = new Protocol.StartSyncMsg();
        msg.frame             = (int)e.m_data["frame"];
        msg.advanceCount      = (int)e.m_data["advancecount"];
        msg.intervalTime      = (int)e.m_data["intervaltime"];
        msg.createEntityIndex = (int)e.m_data["createentityindex"];
        msg.SyncRule          = (SyncRule)e.m_data["syncrule"];

        EventService.DispatchTypeEvent(session, msg);
    }
Exemplo n.º 15
0
    static void RecevicePursueMsg(SyncSession session, ProtocolRequestBase e)
    {
        Protocol.PursueMsg msg = new Protocol.PursueMsg();
        msg.id           = (int)e.m_data["id"];
        msg.recalcFrame  = (int)e.m_data["recalcframe"];
        msg.frame        = (int)e.m_data["frame"];
        msg.advanceCount = (int)e.m_data["advancecount"];
        msg.serverTime   = (int)e.m_data["servertime"];
        msg.updateSpeed  = (float)(double)e.m_data["updatespeed"];

        EventService.DispatchTypeEvent(session, msg);
    }
    static void ReceviceChangeSingletonComponentMsg(SyncSession session, ProtocolRequestBase e)
    {
        Protocol.ChangeSingletonComponentMsg msg = new Protocol.ChangeSingletonComponentMsg();
        msg.frame = (int)e.m_data["frame"];
        {
            Dictionary <string, object> data2 = (Dictionary <string, object>)e.m_data["info"];
            Protocol.ComponentInfo      tmp2  = new Protocol.ComponentInfo();
            tmp2.m_compName = data2["m_compname"].ToString();
            tmp2.content    = data2["content"].ToString();
            msg.info        = tmp2;
        }

        EventService.DispatchTypeEvent(session, msg);
    }
    static void ReceviceCommandComponent(SyncSession session, ProtocolRequestBase e)
    {
        CommandComponent msg = new CommandComponent();

        msg.isForward = (bool)e.m_data["isforward"];
        msg.isBack    = (bool)e.m_data["isback"];
        msg.isRight   = (bool)e.m_data["isright"];
        msg.isLeft    = (bool)e.m_data["isleft"];
        msg.isFire    = (bool)e.m_data["isfire"];
        msg.id        = (int)e.m_data["id"];
        msg.frame     = (int)e.m_data["frame"];

        EventService.DispatchTypeEvent(session, msg);
    }
Exemplo n.º 18
0
        public static void Send(this SyncSession session, ProtocolRequestBase msg)
        {
            ByteArray ba = new ByteArray();

            ba.bytes.AddRange(GetSendByte(msg.Key, msg.m_data));

            byte[] buffer = ba.Buffer;

            bool result = session.TrySend(buffer, 0, buffer.Length);

            if (!result)
            {
                session.Close();
            }
        }
Exemplo n.º 19
0
        public static void Send(this SyncSession session, ProtocolRequestBase msg)
        {
            ByteArray ba = new ByteArray();

            ba.bytes.AddRange(GetSendByte(msg.Key, msg.m_data));

            byte[] buffer = ba.Buffer;

            //bool result =  session.TrySend(buffer, 0, buffer.Length);
            //if(!result)
            //{
            //    session.Close();
            // }
#if KCP
            session.mKcp.Send(buffer);
#endif
        }
Exemplo n.º 20
0
    public static void AnalysisAndDispatchMessage(SyncSession session, ProtocolRequestBase cmd)
    {
        switch (cmd.Key)
        {
        case  "affirmmsg": ReceviceAffirmMsg(session, cmd); break;

        case  "changecomponentmsg": ReceviceChangeComponentMsg(session, cmd); break;

        case  "changesingletoncomponentmsg": ReceviceChangeSingletonComponentMsg(session, cmd); break;

        case  "commandmsg": ReceviceCommandMsg(session, cmd); break;

        case  "debugmsg": ReceviceDebugMsg(session, cmd); break;

        case  "destroyentitymsg": ReceviceDestroyEntityMsg(session, cmd); break;

        case  "pursuemsg": RecevicePursueMsg(session, cmd); break;

        case  "querycommand": ReceviceQueryCommand(session, cmd); break;

        case  "startsyncmsg": ReceviceStartSyncMsg(session, cmd); break;

        case  "syncentitymsg": ReceviceSyncEntityMsg(session, cmd); break;

        case  "commandcomponent": ReceviceCommandComponent(session, cmd); break;

        case  "playerbuycharacter": RecevicePlayerBuyCharacter_s(session, cmd); break;

        case  "playerloginmsg": RecevicePlayerLoginMsg_s(session, cmd); break;

        case  "playermatchmsg": RecevicePlayerMatchMsg_s(session, cmd); break;

        case  "playerrename": RecevicePlayerRename_s(session, cmd); break;

        case  "playerresurgence": RecevicePlayerResurgence_s(session, cmd); break;

        case  "playerselectcharacter": RecevicePlayerSelectCharacter_s(session, cmd); break;

        default:
            Debug.LogError("Recevice Exception : 不支持的消息类型!" + cmd.Key);
            break;
        }
    }
    static void ReceviceCommandMsg(SyncSession session, ProtocolRequestBase e)
    {
        Protocol.CommandMsg msg = new Protocol.CommandMsg();
        msg.frame      = (int)e.m_data["frame"];
        msg.serverTime = (int)e.m_data["servertime"];
        {
            List <Dictionary <string, object> > data2 = (List <Dictionary <string, object> >)e.m_data["msg"];
            List <Protocol.CommandInfo>         list2 = new List <Protocol.CommandInfo>();
            for (int i2 = 0; i2 < data2.Count; i2++)
            {
                Protocol.CommandInfo tmp2 = new Protocol.CommandInfo();
                tmp2.frame = (int)data2[i2]["frame"];
                tmp2.id    = (int)data2[i2]["id"];
                {
                    Dictionary <string, object> data4 = (Dictionary <string, object>)data2[i2]["movedir"];
                    SyncVector3 tmp4 = new SyncVector3();
                    tmp4.x       = (int)data4["x"];
                    tmp4.y       = (int)data4["y"];
                    tmp4.z       = (int)data4["z"];
                    tmp2.moveDir = tmp4;
                }
                {
                    Dictionary <string, object> data4 = (Dictionary <string, object>)data2[i2]["skilldir"];
                    SyncVector3 tmp4 = new SyncVector3();
                    tmp4.x        = (int)data4["x"];
                    tmp4.y        = (int)data4["y"];
                    tmp4.z        = (int)data4["z"];
                    tmp2.skillDir = tmp4;
                }
                tmp2.element1 = (int)data2[i2]["element1"];
                tmp2.element2 = (int)data2[i2]["element2"];
                tmp2.isFire   = (bool)data2[i2]["isfire"];
                list2.Add(tmp2);
            }
            msg.msg = list2;
        }

        EventService.DispatchTypeEvent(session, msg);
    }
    static void ReceviceWaitSyncComponent(SyncSession session, ProtocolRequestBase e)
    {
        LockStepDemo.GameLogic.Component.WaitSyncComponent msg = new LockStepDemo.GameLogic.Component.WaitSyncComponent();

        EventService.DispatchTypeEvent(session, msg);
    }
    static void RecevicePlayerResurgence_s(SyncSession session, ProtocolRequestBase e)
    {
        PlayerResurgence_s msg = new PlayerResurgence_s();

        EventService.DispatchTypeEvent(session, msg);
    }