Example #1
0
        internal static void FindResults(List <AvailableNetworkSession> networkSessions)
        {
            foreach (NetIncomingMessage im in discoveryMsgs)
            {
                AvailableNetworkSession available = new AvailableNetworkSession();
                switch (im.MessageType)
                {
                case NetIncomingMessageType.DiscoveryResponse:
                    int    currentGameCount      = im.ReadInt32();
                    string gamerTag              = im.ReadString();
                    int    openPrivateGamerSlots = im.ReadInt32();
                    int    openPublicGamerSlots  = im.ReadInt32();
                    im.ReadBoolean();                      //isHost

                    NetworkSessionProperties properties = new NetworkSessionProperties();
                    int[] propertyData = new int[properties.Count * 2];
                    for (int x = 0; x < propertyData.Length; x++)
                    {
                        propertyData [x] = im.ReadInt32();
                    }

                    NetworkSessionProperties.ReadProperties(properties, propertyData);
                    available.SessionProperties = properties;

                    available.SessionType           = NetworkSessionType.SystemLink;
                    available.CurrentGamerCount     = currentGameCount;
                    available.HostGamertag          = gamerTag;
                    available.OpenPrivateGamerSlots = openPrivateGamerSlots;
                    available.OpenPublicGamerSlots  = openPublicGamerSlots;
                    available.EndPoint        = im.SenderEndPoint;
                    available.InternalEndpont = null;
                    break;

                case NetIncomingMessageType.UnconnectedData:
                    if (im.SenderEndPoint.Equals(m_masterServer))
                    {
                        currentGameCount      = im.ReadInt32();
                        gamerTag              = im.ReadString();
                        openPrivateGamerSlots = im.ReadInt32();
                        openPublicGamerSlots  = im.ReadInt32();
                        im.ReadBoolean();                          // isHost
                        IPEndPoint hostInternal = im.ReadIPEndPoint();
                        IPEndPoint hostExternal = im.ReadIPEndPoint();
                        available.SessionType           = NetworkSessionType.PlayerMatch;
                        available.CurrentGamerCount     = currentGameCount;
                        available.HostGamertag          = gamerTag;
                        available.OpenPrivateGamerSlots = openPrivateGamerSlots;
                        available.OpenPublicGamerSlots  = openPublicGamerSlots;
                        // its data from the master server so it includes the internal and external endponts
                        available.EndPoint        = hostExternal;
                        available.InternalEndpont = hostInternal;
                    }
                    break;
                }


                networkSessions.Add(available);
            }
        }
Example #2
0
 internal static void FindResults(List <AvailableNetworkSession> networkSessions)
 {
     using (List <NetIncomingMessage> .Enumerator enumerator = MonoGamerPeer.discoveryMsgs.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             NetIncomingMessage      current = enumerator.Current;
             AvailableNetworkSession availableNetworkSession = new AvailableNetworkSession();
             NetIncomingMessageType  messageType             = current.get_MessageType();
             bool flag;
             if (messageType != 2)
             {
                 if (messageType == 64)
                 {
                     int    num1 = current.ReadInt32();
                     string str  = current.ReadString();
                     int    num2 = current.ReadInt32();
                     int    num3 = current.ReadInt32();
                     flag = current.ReadBoolean();
                     NetworkSessionProperties properties = new NetworkSessionProperties();
                     int[] propertyData = new int[properties.Count * 2];
                     for (int index = 0; index < propertyData.Length; ++index)
                     {
                         propertyData[index] = current.ReadInt32();
                     }
                     NetworkSessionProperties.ReadProperties(properties, propertyData);
                     availableNetworkSession.SessionProperties     = properties;
                     availableNetworkSession.SessionType           = NetworkSessionType.SystemLink;
                     availableNetworkSession.CurrentGamerCount     = num1;
                     availableNetworkSession.HostGamertag          = str;
                     availableNetworkSession.OpenPrivateGamerSlots = num2;
                     availableNetworkSession.OpenPublicGamerSlots  = num3;
                     availableNetworkSession.EndPoint        = current.get_SenderEndpoint();
                     availableNetworkSession.InternalEndpont = (IPEndPoint)null;
                 }
             }
             else if (current.get_SenderEndpoint().Equals((object)MonoGamerPeer.m_masterServer))
             {
                 int    num1 = current.ReadInt32();
                 string str  = current.ReadString();
                 int    num2 = current.ReadInt32();
                 int    num3 = current.ReadInt32();
                 flag = current.ReadBoolean();
                 IPEndPoint ipEndPoint1 = current.ReadIPEndpoint();
                 IPEndPoint ipEndPoint2 = current.ReadIPEndpoint();
                 availableNetworkSession.SessionType           = NetworkSessionType.PlayerMatch;
                 availableNetworkSession.CurrentGamerCount     = num1;
                 availableNetworkSession.HostGamertag          = str;
                 availableNetworkSession.OpenPrivateGamerSlots = num2;
                 availableNetworkSession.OpenPublicGamerSlots  = num3;
                 availableNetworkSession.EndPoint        = ipEndPoint2;
                 availableNetworkSession.InternalEndpont = ipEndPoint1;
             }
             networkSessions.Add(availableNetworkSession);
         }
     }
 }