예제 #1
0
 public void Initialize(NetworkClient newClient, MatchInfo newMatchInfo)
 {
     if (LogFilter.logDev)
     {
         Debug.Log("NetworkMigrationManager initialize");
     }
     m_Client    = newClient;
     m_MatchInfo = newMatchInfo;
     newClient.RegisterHandlerSafe(11, OnPeerInfo);
     newClient.RegisterHandlerSafe(18, OnPeerClientAuthority);
     NetworkIdentity.clientAuthorityCallback = AssignAuthorityCallback;
 }
 public void Initialize(NetworkClient newClient, MatchInfo newMatchInfo)
 {
     if (LogFilter.logDev)
     {
         Debug.Log("NetworkMigrationManager initialize");
     }
     this.m_Client    = newClient;
     this.m_MatchInfo = newMatchInfo;
     newClient.RegisterHandlerSafe(11, new NetworkMessageDelegate(this.OnPeerInfo));
     newClient.RegisterHandlerSafe(18, new NetworkMessageDelegate(this.OnPeerClientAuthority));
     NetworkIdentity.clientAuthorityCallback = new NetworkIdentity.ClientAuthorityCallback(this.AssignAuthorityCallback);
 }
예제 #3
0
        public bool BecomeNewHost(int port)
        {
            if (LogFilter.logDebug)
            {
                Debug.Log("NetworkMigrationManager BecomeNewHost " + m_MatchInfo);
            }
            NetworkServer.RegisterHandler(47, OnServerReconnectPlayerMessage);
            NetworkClient networkClient = NetworkServer.BecomeHost(m_Client, port, m_MatchInfo, oldServerConnectionId, peers);

            if (networkClient != null)
            {
                if (NetworkManager.singleton != null)
                {
                    NetworkManager.singleton.RegisterServerMessages();
                    NetworkManager.singleton.UseExternalClient(networkClient);
                }
                else
                {
                    Debug.LogWarning("MigrationManager BecomeNewHost - No NetworkManager.");
                }
                networkClient.RegisterHandlerSafe(11, OnPeerInfo);
                RemovePendingPlayer(m_OldServerConnectionId);
                Reset(-1);
                SendPeerInfo();
                return(true);
            }
            if (LogFilter.logError)
            {
                Debug.LogError("NetworkServer.BecomeHost failed");
            }
            return(false);
        }
        /// <summary>
        ///   <para>This causes a client that has been disconnected from the host to become the new host of the game.</para>
        /// </summary>
        /// <param name="port">The network port to listen on.</param>
        /// <returns>
        ///   <para>True if able to become the new host.</para>
        /// </returns>
        public bool BecomeNewHost(int port)
        {
            if (LogFilter.logDebug)
            {
                Debug.Log((object)("NetworkMigrationManager BecomeNewHost " + (object)this.m_MatchInfo));
            }
            NetworkServer.RegisterHandler((short)47, new NetworkMessageDelegate(this.OnServerReconnectPlayerMessage));
            NetworkClient externalClient = NetworkServer.BecomeHost(this.m_Client, port, this.m_MatchInfo, this.oldServerConnectionId, this.peers);

            if (externalClient != null)
            {
                if ((Object)NetworkManager.singleton != (Object)null)
                {
                    NetworkManager.singleton.RegisterServerMessages();
                    NetworkManager.singleton.UseExternalClient(externalClient);
                }
                else
                {
                    Debug.LogWarning((object)"MigrationManager BecomeNewHost - No NetworkManager.");
                }
                externalClient.RegisterHandlerSafe((short)11, new NetworkMessageDelegate(this.OnPeerInfo));
                this.RemovePendingPlayer(this.m_OldServerConnectionId);
                this.Reset(-1);
                this.SendPeerInfo();
                return(true);
            }
            if (LogFilter.logError)
            {
                Debug.LogError((object)"NetworkServer.BecomeHost failed");
            }
            return(false);
        }
        public bool BecomeNewHost(int port)
        {
            if (LogFilter.logDebug)
            {
                Debug.Log("NetworkMigrationManager BecomeNewHost " + this.m_MatchInfo);
            }
            NetworkServer.RegisterHandler(47, new NetworkMessageDelegate(this.OnServerReconnectPlayerMessage));
            NetworkClient networkClient = NetworkServer.BecomeHost(this.m_Client, port, this.m_MatchInfo, this.oldServerConnectionId, this.peers);
            bool          result;

            if (networkClient != null)
            {
                if (NetworkManager.singleton != null)
                {
                    NetworkManager.singleton.RegisterServerMessages();
                    NetworkManager.singleton.UseExternalClient(networkClient);
                }
                else
                {
                    Debug.LogWarning("MigrationManager BecomeNewHost - No NetworkManager.");
                }
                networkClient.RegisterHandlerSafe(11, new NetworkMessageDelegate(this.OnPeerInfo));
                this.RemovePendingPlayer(this.m_OldServerConnectionId);
                this.Reset(-1);
                this.SendPeerInfo();
                result = true;
            }
            else
            {
                if (LogFilter.logError)
                {
                    Debug.LogError("NetworkServer.BecomeHost failed");
                }
                result = false;
            }
            return(result);
        }
        static internal void RegisterSystemHandlers(NetworkClient client, bool localClient)
        {
            if (localClient)
            {
                client.RegisterHandlerSafe(MsgType.ObjectDestroy, OnLocalClientObjectDestroy);
                client.RegisterHandlerSafe(MsgType.ObjectHide, OnLocalClientObjectHide);
                client.RegisterHandlerSafe(MsgType.ObjectSpawn, OnLocalClientObjectSpawn);
                client.RegisterHandlerSafe(MsgType.ObjectSpawnScene, OnLocalClientObjectSpawnScene);
                client.RegisterHandlerSafe(MsgType.LocalClientAuthority, OnClientAuthority);
            }
            else
            {
                // LocalClient shares the sim/scene with the server, no need for these events
                client.RegisterHandlerSafe(MsgType.ObjectSpawn, OnObjectSpawn);
                client.RegisterHandlerSafe(MsgType.ObjectSpawnScene, OnObjectSpawnScene);
                client.RegisterHandlerSafe(MsgType.SpawnFinished, OnObjectSpawnFinished);
                client.RegisterHandlerSafe(MsgType.ObjectDestroy, OnObjectDestroy);
                client.RegisterHandlerSafe(MsgType.ObjectHide, OnObjectDestroy);
                client.RegisterHandlerSafe(MsgType.UpdateVars, OnUpdateVarsMessage);
                client.RegisterHandlerSafe(MsgType.Owner, OnOwnerMessage);
                client.RegisterHandlerSafe(MsgType.SyncList, OnSyncListMessage);
                client.RegisterHandlerSafe(MsgType.Animation, NetworkAnimator.OnAnimationClientMessage);
                client.RegisterHandlerSafe(MsgType.AnimationParameters, NetworkAnimator.OnAnimationParametersClientMessage);
                client.RegisterHandlerSafe(MsgType.LocalClientAuthority, OnClientAuthority);
            }

            client.RegisterHandlerSafe(MsgType.Rpc, OnRPCMessage);
            client.RegisterHandlerSafe(MsgType.SyncEvent, OnSyncEventMessage);
            client.RegisterHandlerSafe(MsgType.AnimationTrigger, NetworkAnimator.OnAnimationTriggerClientMessage);
        }
 /// <summary>
 ///   <para>Used to initialize the migration manager with client and match information.</para>
 /// </summary>
 /// <param name="newClient">The NetworkClient being used to connect to the host.</param>
 /// <param name="newMatchInfo">Information about the match being used. This may be null if there is no match.</param>
 public void Initialize(NetworkClient newClient, MatchInfo newMatchInfo)
 {
   if (LogFilter.logDev)
     Debug.Log((object) "NetworkMigrationManager initialize");
   this.m_Client = newClient;
   this.m_MatchInfo = newMatchInfo;
   newClient.RegisterHandlerSafe((short) 11, new NetworkMessageDelegate(this.OnPeerInfo));
   newClient.RegisterHandlerSafe((short) 17, new NetworkMessageDelegate(this.OnPeerClientAuthority));
   NetworkIdentity.clientAuthorityCallback = new NetworkIdentity.ClientAuthorityCallback(this.AssignAuthorityCallback);
 }
예제 #8
0
 internal static void RegisterSystemHandlers(NetworkClient client, bool localClient)
 {
     if (localClient)
     {
         client.RegisterHandlerSafe(1, OnLocalClientObjectDestroy);
         client.RegisterHandlerSafe(13, OnLocalClientObjectHide);
         client.RegisterHandlerSafe(3, OnLocalClientObjectSpawn);
         client.RegisterHandlerSafe(10, OnLocalClientObjectSpawnScene);
         client.RegisterHandlerSafe(15, OnClientAuthority);
     }
     else
     {
         client.RegisterHandlerSafe(3, OnObjectSpawn);
         client.RegisterHandlerSafe(10, OnObjectSpawnScene);
         client.RegisterHandlerSafe(12, OnObjectSpawnFinished);
         client.RegisterHandlerSafe(1, OnObjectDestroy);
         client.RegisterHandlerSafe(13, OnObjectDestroy);
         client.RegisterHandlerSafe(8, OnUpdateVarsMessage);
         client.RegisterHandlerSafe(4, OnOwnerMessage);
         client.RegisterHandlerSafe(9, OnSyncListMessage);
         client.RegisterHandlerSafe(40, NetworkAnimator.OnAnimationClientMessage);
         client.RegisterHandlerSafe(41, NetworkAnimator.OnAnimationParametersClientMessage);
         client.RegisterHandlerSafe(15, OnClientAuthority);
     }
     client.RegisterHandlerSafe(2, OnRPCMessage);
     client.RegisterHandlerSafe(7, OnSyncEventMessage);
     client.RegisterHandlerSafe(42, NetworkAnimator.OnAnimationTriggerClientMessage);
 }
예제 #9
0
 internal static void RegisterSystemHandlers(NetworkClient client, bool localClient)
 {
   if (localClient)
   {
     client.RegisterHandlerSafe((short) 1, new NetworkMessageDelegate(ClientScene.OnLocalClientObjectDestroy));
     client.RegisterHandlerSafe((short) 13, new NetworkMessageDelegate(ClientScene.OnLocalClientObjectHide));
     client.RegisterHandlerSafe((short) 3, new NetworkMessageDelegate(ClientScene.OnLocalClientObjectSpawn));
     client.RegisterHandlerSafe((short) 10, new NetworkMessageDelegate(ClientScene.OnLocalClientObjectSpawnScene));
     client.RegisterHandlerSafe((short) 15, new NetworkMessageDelegate(ClientScene.OnClientAuthority));
   }
   else
   {
     client.RegisterHandlerSafe((short) 3, new NetworkMessageDelegate(ClientScene.OnObjectSpawn));
     client.RegisterHandlerSafe((short) 10, new NetworkMessageDelegate(ClientScene.OnObjectSpawnScene));
     client.RegisterHandlerSafe((short) 12, new NetworkMessageDelegate(ClientScene.OnObjectSpawnFinished));
     client.RegisterHandlerSafe((short) 1, new NetworkMessageDelegate(ClientScene.OnObjectDestroy));
     client.RegisterHandlerSafe((short) 13, new NetworkMessageDelegate(ClientScene.OnObjectDestroy));
     client.RegisterHandlerSafe((short) 8, new NetworkMessageDelegate(ClientScene.OnUpdateVarsMessage));
     client.RegisterHandlerSafe((short) 4, new NetworkMessageDelegate(ClientScene.OnOwnerMessage));
     client.RegisterHandlerSafe((short) 9, new NetworkMessageDelegate(ClientScene.OnSyncListMessage));
     client.RegisterHandlerSafe((short) 40, new NetworkMessageDelegate(NetworkAnimator.OnAnimationClientMessage));
     client.RegisterHandlerSafe((short) 41, new NetworkMessageDelegate(NetworkAnimator.OnAnimationParametersClientMessage));
     client.RegisterHandlerSafe((short) 15, new NetworkMessageDelegate(ClientScene.OnClientAuthority));
   }
   client.RegisterHandlerSafe((short) 2, new NetworkMessageDelegate(ClientScene.OnRPCMessage));
   client.RegisterHandlerSafe((short) 7, new NetworkMessageDelegate(ClientScene.OnSyncEventMessage));
   client.RegisterHandlerSafe((short) 42, new NetworkMessageDelegate(NetworkAnimator.OnAnimationTriggerClientMessage));
 }
예제 #10
0
 internal static void RegisterSystemHandlers(NetworkClient client, bool localClient)
 {
     if (localClient)
     {
         client.RegisterHandlerSafe((short)1, new NetworkMessageDelegate(ClientScene.OnLocalClientObjectDestroy));
         client.RegisterHandlerSafe((short)13, new NetworkMessageDelegate(ClientScene.OnLocalClientObjectHide));
         client.RegisterHandlerSafe((short)3, new NetworkMessageDelegate(ClientScene.OnLocalClientObjectSpawn));
         client.RegisterHandlerSafe((short)10, new NetworkMessageDelegate(ClientScene.OnLocalClientObjectSpawnScene));
         client.RegisterHandlerSafe((short)15, new NetworkMessageDelegate(ClientScene.OnClientAuthority));
     }
     else
     {
         client.RegisterHandlerSafe((short)3, new NetworkMessageDelegate(ClientScene.OnObjectSpawn));
         client.RegisterHandlerSafe((short)10, new NetworkMessageDelegate(ClientScene.OnObjectSpawnScene));
         client.RegisterHandlerSafe((short)12, new NetworkMessageDelegate(ClientScene.OnObjectSpawnFinished));
         client.RegisterHandlerSafe((short)1, new NetworkMessageDelegate(ClientScene.OnObjectDestroy));
         client.RegisterHandlerSafe((short)13, new NetworkMessageDelegate(ClientScene.OnObjectDestroy));
         client.RegisterHandlerSafe((short)8, new NetworkMessageDelegate(ClientScene.OnUpdateVarsMessage));
         client.RegisterHandlerSafe((short)4, new NetworkMessageDelegate(ClientScene.OnOwnerMessage));
         client.RegisterHandlerSafe((short)9, new NetworkMessageDelegate(ClientScene.OnSyncListMessage));
         client.RegisterHandlerSafe((short)40, new NetworkMessageDelegate(NetworkAnimator.OnAnimationClientMessage));
         client.RegisterHandlerSafe((short)41, new NetworkMessageDelegate(NetworkAnimator.OnAnimationParametersClientMessage));
         client.RegisterHandlerSafe((short)15, new NetworkMessageDelegate(ClientScene.OnClientAuthority));
     }
     client.RegisterHandlerSafe((short)2, new NetworkMessageDelegate(ClientScene.OnRPCMessage));
     client.RegisterHandlerSafe((short)7, new NetworkMessageDelegate(ClientScene.OnSyncEventMessage));
     client.RegisterHandlerSafe((short)42, new NetworkMessageDelegate(NetworkAnimator.OnAnimationTriggerClientMessage));
 }
예제 #11
0
        internal static void RegisterSystemHandlers(NetworkClient client, bool localClient)
        {
            if (localClient)
            {
                short msgType = 1;
                if (ClientScene.< > f__mg$cache0 == null)
                {
                    ClientScene.< > f__mg$cache0 = new NetworkMessageDelegate(ClientScene.OnLocalClientObjectDestroy);
                }
                client.RegisterHandlerSafe(msgType, ClientScene.< > f__mg$cache0);
                short msgType2 = 13;
                if (ClientScene.< > f__mg$cache1 == null)
                {
                    ClientScene.< > f__mg$cache1 = new NetworkMessageDelegate(ClientScene.OnLocalClientObjectHide);
                }
                client.RegisterHandlerSafe(msgType2, ClientScene.< > f__mg$cache1);
                short msgType3 = 3;
                if (ClientScene.< > f__mg$cache2 == null)
                {
                    ClientScene.< > f__mg$cache2 = new NetworkMessageDelegate(ClientScene.OnLocalClientObjectSpawn);
                }
                client.RegisterHandlerSafe(msgType3, ClientScene.< > f__mg$cache2);
                short msgType4 = 10;
                if (ClientScene.< > f__mg$cache3 == null)
                {
                    ClientScene.< > f__mg$cache3 = new NetworkMessageDelegate(ClientScene.OnLocalClientObjectSpawnScene);
                }
                client.RegisterHandlerSafe(msgType4, ClientScene.< > f__mg$cache3);
                short msgType5 = 15;
                if (ClientScene.< > f__mg$cache4 == null)
                {
                    ClientScene.< > f__mg$cache4 = new NetworkMessageDelegate(ClientScene.OnClientAuthority);
                }
                client.RegisterHandlerSafe(msgType5, ClientScene.< > f__mg$cache4);
            }
            else
            {
                short msgType6 = 3;
                if (ClientScene.< > f__mg$cache5 == null)
                {
                    ClientScene.< > f__mg$cache5 = new NetworkMessageDelegate(ClientScene.OnObjectSpawn);
                }
                client.RegisterHandlerSafe(msgType6, ClientScene.< > f__mg$cache5);
                short msgType7 = 10;
                if (ClientScene.< > f__mg$cache6 == null)
                {
                    ClientScene.< > f__mg$cache6 = new NetworkMessageDelegate(ClientScene.OnObjectSpawnScene);
                }
                client.RegisterHandlerSafe(msgType7, ClientScene.< > f__mg$cache6);
                short msgType8 = 12;
                if (ClientScene.< > f__mg$cache7 == null)
                {
                    ClientScene.< > f__mg$cache7 = new NetworkMessageDelegate(ClientScene.OnObjectSpawnFinished);
                }
                client.RegisterHandlerSafe(msgType8, ClientScene.< > f__mg$cache7);
                short msgType9 = 1;
                if (ClientScene.< > f__mg$cache8 == null)
                {
                    ClientScene.< > f__mg$cache8 = new NetworkMessageDelegate(ClientScene.OnObjectDestroy);
                }
                client.RegisterHandlerSafe(msgType9, ClientScene.< > f__mg$cache8);
                short msgType10 = 13;
                if (ClientScene.< > f__mg$cache9 == null)
                {
                    ClientScene.< > f__mg$cache9 = new NetworkMessageDelegate(ClientScene.OnObjectDestroy);
                }
                client.RegisterHandlerSafe(msgType10, ClientScene.< > f__mg$cache9);
                short msgType11 = 8;
                if (ClientScene.< > f__mg$cacheA == null)
                {
                    ClientScene.< > f__mg$cacheA = new NetworkMessageDelegate(ClientScene.OnUpdateVarsMessage);
                }
                client.RegisterHandlerSafe(msgType11, ClientScene.< > f__mg$cacheA);
                short msgType12 = 4;
                if (ClientScene.< > f__mg$cacheB == null)
                {
                    ClientScene.< > f__mg$cacheB = new NetworkMessageDelegate(ClientScene.OnOwnerMessage);
                }
                client.RegisterHandlerSafe(msgType12, ClientScene.< > f__mg$cacheB);
                short msgType13 = 9;
                if (ClientScene.< > f__mg$cacheC == null)
                {
                    ClientScene.< > f__mg$cacheC = new NetworkMessageDelegate(ClientScene.OnSyncListMessage);
                }
                client.RegisterHandlerSafe(msgType13, ClientScene.< > f__mg$cacheC);
                short msgType14 = 40;
                if (ClientScene.< > f__mg$cacheD == null)
                {
                    ClientScene.< > f__mg$cacheD = new NetworkMessageDelegate(NetworkAnimator.OnAnimationClientMessage);
                }
                client.RegisterHandlerSafe(msgType14, ClientScene.< > f__mg$cacheD);
                short msgType15 = 41;
                if (ClientScene.< > f__mg$cacheE == null)
                {
                    ClientScene.< > f__mg$cacheE = new NetworkMessageDelegate(NetworkAnimator.OnAnimationParametersClientMessage);
                }
                client.RegisterHandlerSafe(msgType15, ClientScene.< > f__mg$cacheE);
                short msgType16 = 15;
                if (ClientScene.< > f__mg$cacheF == null)
                {
                    ClientScene.< > f__mg$cacheF = new NetworkMessageDelegate(ClientScene.OnClientAuthority);
                }
                client.RegisterHandlerSafe(msgType16, ClientScene.< > f__mg$cacheF);
            }
            short msgType17 = 2;

            if (ClientScene.< > f__mg$cache10 == null)
            {
                ClientScene.< > f__mg$cache10 = new NetworkMessageDelegate(ClientScene.OnRPCMessage);
            }
            client.RegisterHandlerSafe(msgType17, ClientScene.< > f__mg$cache10);
            short msgType18 = 7;

            if (ClientScene.< > f__mg$cache11 == null)
            {
                ClientScene.< > f__mg$cache11 = new NetworkMessageDelegate(ClientScene.OnSyncEventMessage);
            }
            client.RegisterHandlerSafe(msgType18, ClientScene.< > f__mg$cache11);
            short msgType19 = 42;

            if (ClientScene.< > f__mg$cache12 == null)
            {
                ClientScene.< > f__mg$cache12 = new NetworkMessageDelegate(NetworkAnimator.OnAnimationTriggerClientMessage);
            }
            client.RegisterHandlerSafe(msgType19, ClientScene.< > f__mg$cache12);
        }