示例#1
0
    public static void SendStartMsg(WorldBase world)
    {
        //获取所有的Player组件,并派发
        List <EntityBase> list = world.GetEntityList(s_playerFilter);

        StartSyncMsg startMsg = CreateStartMsg(world);

        SyncEntityMsg playerInfo = new SyncEntityMsg();

        playerInfo.frame = world.FrameCount;
        playerInfo.infos = new List <EntityInfo>();

        for (int i = 0; i < list.Count; i++)
        {
            playerInfo.infos.Add(CreatePlayerComponentInfo(list[i]));
        }

        for (int i = 0; i < list.Count; i++)
        {
            ConnectionComponent cc          = list[i].GetComp <ConnectionComponent>();
            SyncEntityMsg       serviceInfo = CreateServiceMsg(world, cc.m_session);

            ProtocolAnalysisService.SendMsg(cc.m_session, playerInfo);
            ProtocolAnalysisService.SendMsg(cc.m_session, serviceInfo);
            ProtocolAnalysisService.SendMsg(cc.m_session, startMsg);
        }
    }
    public void OnGameFinsih(params object[] objs)
    {
        WorldBase world = (WorldBase)objs[0];

        List <EntityBase> list = world.GetEntityList(new string[] { "ConnectionComponent" });

        //移除所有的重连信息
        for (int i = 0; i < list.Count; i++)
        {
            ConnectionComponent cc = list[i].GetComp <ConnectionComponent>();
            m_disConnectDict.Remove(cc.m_playerID);

            RemoveRecord(cc.m_playerID);
        }
    }
示例#3
0
    static void BroadcastSameCommand(WorldBase world, ConnectionComponent connectComp, SameCommand cmd, bool includeSelf)
    {
        cmd.time = ServiceTime.GetServiceTime();

        List <EntityBase> list = world.GetEntityList(new string[] { "ConnectionComponent" });

        for (int i = 0; i < list.Count; i++)
        {
            ConnectionComponent cp = list[i].GetComp <ConnectionComponent>();
            if (cp.m_session != null)
            {
                ProtocolAnalysisService.SendMsg(cp.m_session, cmd);
                //Debug.Log("BroadcastSameCommand " + cmd.frame);
            }
        }
    }
示例#4
0
    public static SyncEntityMsg CreateServiceMsg(WorldBase world, SyncSession session)
    {
        SyncEntityMsg serviceInfo = new SyncEntityMsg();

        serviceInfo.frame = world.FrameCount;
        serviceInfo.infos = new List <EntityInfo>();

        List <EntityBase> list = world.GetEntityList(s_playerFilter);

        for (int i = 0; i < list.Count; i++)
        {
            serviceInfo.infos.Add(CreateServiceComponentInfo(list[i], session));
        }

        return(serviceInfo);
    }