示例#1
0
    public void RunService(int serverPort)
    {
        if (m_actorManager != null)
        {
            return;
        }

        m_actorManager = new ActorManager();

        m_watchDogActor = new WatchDogActor(this);
        //Id为1的Actor, 不与Agent绑定,也没有U3DId标识
        m_actorManager.AddActor(m_watchDogActor, true);

        m_worldActor = new WorldActor(this);
        m_watchDogActor.WorldActor = m_worldActor;
        //Id为2的Actor, 不与Agent绑定,也没有U3DId标识
        m_actorManager.AddActor(m_worldActor, true);

        m_serverActor = new ServerActor(this);
        m_watchDogActor.ServerActor = m_serverActor;
        m_serverActor.WatchDogActor = m_watchDogActor;
        //Id为3的Actor, 不与Agent绑定,也没有U3DId标识
        m_actorManager.AddActor(m_serverActor, true);

        //启动服务器
        m_serverActor.Run(serverPort);
    }
示例#2
0
 public void StopDogActorAndWorldActor()
 {
     if (m_actorManager != null)
     {
         if (m_watchDogActor != null)
         {
             m_watchDogActor.Stop();
             m_actorManager.RemoveActor(m_watchDogActor.Id);
             m_watchDogActor = null;
         }
         if (m_worldActor != null)
         {
             m_worldActor.Stop();
             m_actorManager.RemoveActor(m_worldActor.Id);
             m_worldActor = null;
         }
         m_actorManager = null;
     }
 }