Internal UNET message for sending information about network peers to clients.

Inheritance: UnityEngine.Networking.MessageBase
 /// <summary>
 ///   <para>A virtual function that is called when the set of peers in the game changes.</para>
 /// </summary>
 /// <param name="peers">The set of peers in the game.</param>
 protected virtual void OnPeersUpdated(PeerListMessage peers)
 {
   if (!LogFilter.logDev)
     return;
   Debug.Log((object) ("NetworkMigrationManager NumPeers " + (object) peers.peers.Length));
 }
 /// <summary>
 ///   <para>This sends the set of peers in the game to all the peers in the game.</para>
 /// </summary>
 public void SendPeerInfo()
 {
   if (!this.m_HostMigration)
     return;
   PeerListMessage peerListMessage = new PeerListMessage();
   List<PeerInfoMessage> peerInfoMessageList = new List<PeerInfoMessage>();
   for (int index = 0; index < NetworkServer.connections.Count; ++index)
   {
     NetworkConnection connection = NetworkServer.connections[index];
     if (connection != null)
     {
       PeerInfoMessage peerInfoMessage = new PeerInfoMessage();
       string address;
       int port;
       NetworkID network;
       NodeID dstNode;
       byte error;
       NetworkTransport.GetConnectionInfo(NetworkServer.serverHostId, connection.connectionId, out address, out port, out network, out dstNode, out error);
       peerInfoMessage.connectionId = connection.connectionId;
       peerInfoMessage.port = port;
       if (index == 0)
       {
         peerInfoMessage.port = NetworkServer.listenPort;
         peerInfoMessage.isHost = true;
         peerInfoMessage.address = "<host>";
       }
       else
       {
         peerInfoMessage.address = address;
         peerInfoMessage.isHost = false;
       }
       List<PeerInfoPlayer> peerInfoPlayerList = new List<PeerInfoPlayer>();
       using (List<PlayerController>.Enumerator enumerator = connection.playerControllers.GetEnumerator())
       {
         while (enumerator.MoveNext())
         {
           PlayerController current = enumerator.Current;
           if (current != null && (Object) current.unetView != (Object) null)
           {
             PeerInfoPlayer peerInfoPlayer;
             peerInfoPlayer.netId = current.unetView.netId;
             peerInfoPlayer.playerControllerId = current.unetView.playerControllerId;
             peerInfoPlayerList.Add(peerInfoPlayer);
           }
         }
       }
       if (connection.clientOwnedObjects != null)
       {
         using (HashSet<NetworkInstanceId>.Enumerator enumerator = connection.clientOwnedObjects.GetEnumerator())
         {
           while (enumerator.MoveNext())
           {
             NetworkInstanceId current = enumerator.Current;
             GameObject localObject = NetworkServer.FindLocalObject(current);
             if (!((Object) localObject == (Object) null) && (int) localObject.GetComponent<NetworkIdentity>().playerControllerId == -1)
             {
               PeerInfoPlayer peerInfoPlayer;
               peerInfoPlayer.netId = current;
               peerInfoPlayer.playerControllerId = (short) -1;
               peerInfoPlayerList.Add(peerInfoPlayer);
             }
           }
         }
       }
       if (peerInfoPlayerList.Count > 0)
         peerInfoMessage.playerIds = peerInfoPlayerList.ToArray();
       peerInfoMessageList.Add(peerInfoMessage);
     }
   }
   peerListMessage.peers = peerInfoMessageList.ToArray();
   for (int index = 0; index < NetworkServer.connections.Count; ++index)
   {
     NetworkConnection connection = NetworkServer.connections[index];
     if (connection != null)
     {
       peerListMessage.oldServerConnectionId = connection.connectionId;
       connection.Send((short) 11, (MessageBase) peerListMessage);
     }
   }
 }
 /// <summary>
 /// <para>This sends the set of peers in the game to all the peers in the game.</para>
 /// </summary>
 public void SendPeerInfo()
 {
     if (this.m_HostMigration)
     {
         PeerListMessage msg = new PeerListMessage();
         List<PeerInfoMessage> list = new List<PeerInfoMessage>();
         for (int i = 0; i < NetworkServer.connections.Count; i++)
         {
             NetworkConnection connection = NetworkServer.connections[i];
             if (connection != null)
             {
                 string str;
                 int num2;
                 NetworkID kid;
                 NodeID eid;
                 byte num3;
                 PeerInfoMessage item = new PeerInfoMessage();
                 NetworkTransport.GetConnectionInfo(NetworkServer.serverHostId, connection.connectionId, out str, out num2, out kid, out eid, out num3);
                 item.connectionId = connection.connectionId;
                 item.port = num2;
                 if (i == 0)
                 {
                     item.port = NetworkServer.listenPort;
                     item.isHost = true;
                     item.address = "<host>";
                 }
                 else
                 {
                     item.address = str;
                     item.isHost = false;
                 }
                 List<PeerInfoPlayer> list2 = new List<PeerInfoPlayer>();
                 for (int k = 0; k < connection.playerControllers.Count; k++)
                 {
                     PlayerController controller = connection.playerControllers[k];
                     if ((controller != null) && (controller.unetView != null))
                     {
                         PeerInfoPlayer player;
                         player.netId = controller.unetView.netId;
                         player.playerControllerId = controller.unetView.playerControllerId;
                         list2.Add(player);
                     }
                 }
                 if (connection.clientOwnedObjects != null)
                 {
                     foreach (NetworkInstanceId id in connection.clientOwnedObjects)
                     {
                         GameObject obj2 = NetworkServer.FindLocalObject(id);
                         if ((obj2 != null) && (obj2.GetComponent<NetworkIdentity>().playerControllerId == -1))
                         {
                             PeerInfoPlayer player2;
                             player2.netId = id;
                             player2.playerControllerId = -1;
                             list2.Add(player2);
                         }
                     }
                 }
                 if (list2.Count > 0)
                 {
                     item.playerIds = list2.ToArray();
                 }
                 list.Add(item);
             }
         }
         msg.peers = list.ToArray();
         for (int j = 0; j < NetworkServer.connections.Count; j++)
         {
             NetworkConnection connection2 = NetworkServer.connections[j];
             if (connection2 != null)
             {
                 msg.oldServerConnectionId = connection2.connectionId;
                 connection2.Send(11, msg);
             }
         }
     }
 }
 /// <summary>
 /// 
 /// <para>
 /// This sends information about all participants in the current network game to the connection.
 /// </para>
 /// 
 /// </summary>
 /// <param name="targetConnection">Connection to send peer info to.</param>
 public void SendNetworkInfo(NetworkConnection targetConnection)
 {
     PeerListMessage peerListMessage = new PeerListMessage();
       List<PeerInfoMessage> list = new List<PeerInfoMessage>();
       for (int connId = 0; connId < this.m_Connections.Count; ++connId)
       {
     NetworkConnection networkConnection = this.m_Connections.Get(connId);
     if (networkConnection != null)
     {
       PeerInfoMessage peerInfoMessage = new PeerInfoMessage();
       string address;
       int port;
       NetworkID network;
       NodeID dstNode;
       byte error;
       NetworkTransport.GetConnectionInfo(this.m_ServerId, networkConnection.connectionId, out address, out port, out network, out dstNode, out error);
       peerInfoMessage.connectionId = networkConnection.connectionId;
       peerInfoMessage.address = address;
       peerInfoMessage.port = port;
       peerInfoMessage.isHost = false;
       peerInfoMessage.isYou = networkConnection == targetConnection;
       list.Add(peerInfoMessage);
     }
       }
       if (NetworkServer.localClientActive)
     list.Add(new PeerInfoMessage()
     {
       address = "HOST",
       port = this.m_ServerPort,
       connectionId = 0,
       isHost = true,
       isYou = false
     });
       peerListMessage.peers = list.ToArray();
       for (int connId = 0; connId < this.m_Connections.Count; ++connId)
       {
     NetworkConnection networkConnection = this.m_Connections.Get(connId);
     if (networkConnection != null)
       networkConnection.Send((short) 11, (MessageBase) peerListMessage);
       }
 }
 /// <summary>
 /// <para>A virtual function that is called when the set of peers in the game changes.</para>
 /// </summary>
 /// <param name="peers">The set of peers in the game.</param>
 protected virtual void OnPeersUpdated(PeerListMessage peers)
 {
     if (LogFilter.logDev)
     {
         Debug.Log("NetworkMigrationManager NumPeers " + peers.peers.Length);
     }
 }