public SearchLocalNetworkScreen(PlayerIndex playerIndex, AvailableNetworkSessionCollection availableSessions)
            : base("Local Network Game Search")
        {
            currentPlayer = playerIndex;
            IsPopupWindow = true;
            this.availableSessions = availableSessions;
            if (availableSessions.Count == 0)
            {
                Games = new MenuEntry("No Games found");
                returnEntry = new MenuEntry("Return");
                MenuEntries.Add(Games);
            }
            else
            {
                gameCount = 0;
                totalGames = availableSessions.Count;
                currentSessionSelected = availableSessions[0];
                Games = new MenuEntry("Game: 0 / " + gameCount);
                gameMode = new MenuEntry("Game mode: " + GameType());
                highScore = new MenuEntry("Hi score: " + WinningScore());
                joinGame = new MenuEntry("Join this game");

                joinGame.Selected += JoinSession;
                MenuEntries.Add(Games);
                MenuEntries.Add(gameMode);
                MenuEntries.Add(highScore);
                MenuEntries.Add(joinGame);

            }

            // hook up event handlers
            returnEntry.Selected += GoBack;

            MenuEntries.Add(returnEntry);
        }
Exemple #2
0
        public static IAsyncResult BeginJoin(
            AvailableNetworkSession availableSession,
            AsyncCallback callback,
            object asyncState
            )
        {
            if (availableSession == null)
            {
                throw new ArgumentNullException("availableSession");
            }
            if (activeAction != null || activeSession != null)
            {
                throw new InvalidOperationException();
            }

            activeAction = new NetworkSessionAction(
                asyncState,
                callback,
                4,                 // FIXME
                null,
                0,
                null,
                NetworkSessionType.PlayerMatch                 // FIXME
                );
            return(activeAction);
        }
Exemple #3
0
 public static IAsyncResult BeginJoin(AvailableNetworkSession availableSession, AsyncCallback callback, object asyncState)
 {
   if (availableSession == null)
     throw new ArgumentNullException();
   else
     return new NetworkSessionAsynchronousJoin(NetworkSession.JoinSession).BeginInvoke(availableSession, callback, asyncState);
 }
Exemple #4
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);
            }
        }
Exemple #5
0
        public static NetworkSession Join(AvailableNetworkSession availableSession)
        {
#if WINDOWS_PHONE
            return(JoinSession(availableSession));
#else
            return(EndJoin(BeginJoin(availableSession, null, null)));
#endif
        }
        /// <summary>
        /// Formats session information to create the menu text string.
        /// </summary>
        static string GetMenuItemText(AvailableNetworkSession session)
        {
            int totalSlots = session.CurrentGamerCount +
                             session.OpenPublicGamerSlots;

            return string.Format("{0} ({1}/{2})", session.HostGamertag,
                                                  session.CurrentGamerCount,
                                                  totalSlots);
        }
Exemple #7
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);
         }
     }
 }
Exemple #8
0
 private static NetworkSession JoinSession(AvailableNetworkSession availableSession)
 {
   NetworkSessionType sessionType = availableSession.SessionType;
   int maxGamers = 32;
   int privateGamerSlots = 0;
   bool isHost = false;
   int hostGamer = -1;
   NetworkSessionProperties sessionProperties = availableSession.SessionProperties ?? new NetworkSessionProperties();
   return new NetworkSession(sessionType, maxGamers, privateGamerSlots, sessionProperties, isHost, hostGamer, availableSession);
 }
Exemple #9
0
 public MonoGamerPeer(NetworkSession session, AvailableNetworkSession availableSession)
 {
     this.session          = session;
     this.online           = this.session.SessionType == NetworkSessionType.PlayerMatch;
     this.availableSession = availableSession;
     this.MGServerWorker.WorkerSupportsCancellation = true;
     this.MGServerWorker.DoWork             += new DoWorkEventHandler(this.MGServer_DoWork);
     this.MGServerWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.MGServer_RunWorkerCompleted);
     this.MGServerWorker.RunWorkerAsync();
     this.HookEvents();
 }
 public AvailableNetworkSessionDisplayTextSprite(SpriteBatch sb, float prevY, AvailableNetworkSession sessToRepresent)
     : base(sb, new Vector2(0, prevY + GameContent.Assets.Fonts.NormalText.LineSpacing * 2 + 5), GameContent.Assets.Fonts.NormalText, string.Format("{0}'s {3} session:\n{1} out of {2} gamers", sessToRepresent.HostGamertag, sessToRepresent.CurrentGamerCount, sessToRepresent.CurrentGamerCount + sessToRepresent.OpenPrivateGamerSlots + sessToRepresent.OpenPublicGamerSlots, "{0}"), Color.White)
 {
     SessionType = Enum.Parse(typeof(MultiplayerSessionType), sessToRepresent.SessionProperties[(int)NetworkSessionPropertyType.SessionType].ToString(), true).Cast<MultiplayerSessionType>();
     Text = string.Format(Text, SessionType.ToFriendlyString().ToLower());
     Session = sessToRepresent;
     HoverColor = Color.MediumAquamarine;
     NonHoverColor = Color.White;
     IsHoverable = true;
     X = this.GetCenterPosition(sb.GraphicsDevice.Viewport).X;
 }
Exemple #11
0
 public MonoGamerPeer(NetworkSession session, AvailableNetworkSession availableSession)
 {
   this.session = session;
   this.online = this.session.SessionType == NetworkSessionType.PlayerMatch;
   this.availableSession = availableSession;
   this.MGServerWorker.WorkerSupportsCancellation = true;
   this.MGServerWorker.DoWork += new DoWorkEventHandler(this.MGServer_DoWork);
   this.MGServerWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.MGServer_RunWorkerCompleted);
   this.MGServerWorker.RunWorkerAsync();
   this.HookEvents();
 }
Exemple #12
0
        public MonoGamerPeer(NetworkSession session, AvailableNetworkSession availableSession)
        {
#if !PORTABLE
            this.session          = session;
            this.online           = this.session.SessionType == NetworkSessionType.PlayerMatch;
            this.availableSession = availableSession;
            //MGServerWorker.WorkerReportsProgress = true;
            MGServerWorker.WorkerSupportsCancellation = true;
            MGServerWorker.DoWork             += new DoWorkEventHandler(MGServer_DoWork);
            MGServerWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(MGServer_RunWorkerCompleted);
            MGServerWorker.RunWorkerAsync();

            HookEvents();
#endif
        }
Exemple #13
0
        public static NetworkSession Join(AvailableNetworkSession availableSession)
        {
            if (availableSession == null)
            {
                throw new ArgumentNullException();
            }

            try
            {
                throw new NotImplementedException();
            }
            finally
            {
            }
        }
Exemple #14
0
        public static NetworkSession Join(
            AvailableNetworkSession availableSession
            )
        {
            IAsyncResult result = BeginJoin(availableSession, null, null);

            while (!result.IsCompleted)
            {
                if (!GamerServicesDispatcher.UpdateAsync())
                {
                    activeAction.IsCompleted = true;
                }
            }
            return(EndJoin(result));
        }
        public static IAsyncResult BeginJoin(
            AvailableNetworkSession availableSession,
            AsyncCallback callback,
            Object asyncState)
        {
            if (availableSession == null)
            {
                throw new ArgumentNullException();
            }

            try {
                NetworkSessionAsynchronousJoin AsynchronousJoin = new NetworkSessionAsynchronousJoin(JoinSession);
                return(AsynchronousJoin.BeginInvoke(availableSession, callback, asyncState));
            } finally {
            }
        }
        private static NetworkSession JoinSession(AvailableNetworkSession availableSession)
        {
            NetworkSession session = null;

            try {
                NetworkSessionType sessionType = availableSession.SessionType;
                int  maxGamers         = 32;
                int  privateGamerSlots = 0;
                bool isHost            = false;
                int  hostGamer         = -1;
                NetworkSessionProperties sessionProperties = availableSession.SessionProperties;
                if (sessionProperties == null)
                {
                    sessionProperties = new NetworkSessionProperties();
                }
                session = new NetworkSession(sessionType, maxGamers, privateGamerSlots, sessionProperties, isHost, hostGamer, availableSession);
            } finally {
            }

            return(session);
        }
 public static NetworkSession Join(AvailableNetworkSession availableSession)
 {
     return(EndJoin(BeginJoin(availableSession, null, null)));
 }
        private NetworkSession(NetworkSessionType sessionType, int maxGamers, int privateGamerSlots, NetworkSessionProperties sessionProperties, bool isHost, int hostGamer, AvailableNetworkSession availableSession) : this()
        {
            if (sessionProperties == null)
            {
                throw new ArgumentNullException("sessionProperties");
            }

            _allGamers   = new GamerCollection <NetworkGamer>();
            _localGamers = new GamerCollection <LocalNetworkGamer>();
//			for (int x = 0; x < Gamer.SignedInGamers.Count; x++) {
//				GamerStates states = GamerStates.Local;
//				if (x == 0)
//					states |= GamerStates.Host;
//				LocalNetworkGamer localGamer = new LocalNetworkGamer(this, (byte)x, states);
//				localGamer.SignedInGamer = Gamer.SignedInGamers[x];
//				_allGamers.AddGamer(localGamer);
//				_localGamers.AddGamer(localGamer);
//
//				// We will attach a property change handler to local gamers
//				//  se that we can broadcast the change to other peers.
//				localGamer.PropertyChanged += HandleGamerPropertyChanged;
//
//			}

            _remoteGamers   = new GamerCollection <NetworkGamer>();
            _previousGamers = new GamerCollection <NetworkGamer>();
            hostingGamer    = null;

            commandQueue = new Queue <CommandEvent>();

            this.sessionType       = sessionType;
            this.maxGamers         = maxGamers;
            this.privateGamerSlots = privateGamerSlots;
            this.sessionProperties = sessionProperties;
            this.isHost            = isHost;
            this.hostGamerIndex    = hostGamer;
            if (isHost)
            {
                networkPeer = new MonoGamerPeer(this, null);
            }
            else
            {
                if (networkPeer == null)
                {
                    networkPeer = new MonoGamerPeer(this, availableSession);
                }
            }

            CommandGamerJoined gj = new CommandGamerJoined(hostGamer, this.isHost, true);

            commandQueue.Enqueue(new CommandEvent(gj));
        }
Exemple #19
0
		public static IAsyncResult BeginJoin (
			AvailableNetworkSession availableSession,
			AsyncCallback callback,
			Object asyncState)
		{
			if (availableSession == null)
				throw new ArgumentNullException ();			

			try {
				NetworkSessionAsynchronousJoin AsynchronousJoin = new NetworkSessionAsynchronousJoin (JoinSession);
				return AsynchronousJoin.BeginInvoke (availableSession, callback, asyncState);
			} finally {
			}
		}
Exemple #20
0
 public static IAsyncResult BeginJoin(AvailableNetworkSession availableSession, AsyncCallback callback, object asyncState)
 {
     throw new NotImplementedException();
 }
 public SessionInfoDisplay(SpriteBatch s, Vector2 v, SpriteFont f, string t, AvailableNetworkSession sess)
     : base(s, v, f, t)
 {
     Session = sess;
 }
 /// <summary>
 /// Constructs a menu entry describing an available network session.
 /// </summary>
 public AvailableSessionMenuEntry(AvailableNetworkSession availableSession)
     : base(GetMenuItemText(availableSession))
 {
     this.availableSession = availableSession;
 }
Exemple #23
0
 public static IAsyncResult BeginJoin(AvailableNetworkSession availableSession, AsyncCallback callback, object asyncState)
 {
     throw new NotImplementedException();
 }
Exemple #24
0
 private NetworkSession(NetworkSessionType sessionType, int maxGamers, int privateGamerSlots, NetworkSessionProperties sessionProperties, bool isHost, int hostGamer, AvailableNetworkSession availableSession)
   : this()
 {
   if (sessionProperties == null)
     throw new ArgumentNullException("sessionProperties");
   this._allGamers = new GamerCollection<NetworkGamer>();
   this._localGamers = new GamerCollection<LocalNetworkGamer>();
   this._remoteGamers = new GamerCollection<NetworkGamer>();
   this._previousGamers = new GamerCollection<NetworkGamer>();
   this.hostingGamer = (NetworkGamer) null;
   this.commandQueue = new Queue<CommandEvent>();
   this.sessionType = sessionType;
   this.maxGamers = maxGamers;
   this.privateGamerSlots = privateGamerSlots;
   this.sessionProperties = sessionProperties;
   this.isHost = isHost;
   this.hostGamerIndex = hostGamer;
   this.commandQueue.Enqueue(new CommandEvent((ICommand) new CommandGamerJoined(hostGamer, this.isHost, true)));
 }
Exemple #25
0
        public void JoinSession(AvailableNetworkSession hostSession)
        {
            session = NetworkSession.Join(hostSession);

            pr = new PacketReader();
            pw = new PacketWriter();

            sender = session.LocalGamers[0];
        }
Exemple #26
0
		public static NetworkSession Join (AvailableNetworkSession availableSession)
		{
#if WINDOWS_PHONE
            return JoinSession(availableSession);
#else
			return EndJoin(BeginJoin(availableSession, null, null));
#endif

		}
Exemple #27
0
 public RemoteGame(AvailableNetworkSession aSession)
 {
     session = aSession;
 }
 internal AvailableSession(AvailableNetworkSession session)
 {
     NativeSession = session;
 }
Exemple #29
0
 public static NetworkSession Join(AvailableNetworkSession availableSession)
 {
     return EndJoin(BeginJoin(availableSession, null, null));
 }
Exemple #30
0
		private NetworkSession (NetworkSessionType sessionType, int maxGamers, int privateGamerSlots, NetworkSessionProperties sessionProperties, bool isHost, int hostGamer, AvailableNetworkSession availableSession) : this()
		{
			if (sessionProperties == null) {
				throw new ArgumentNullException ("sessionProperties");
			}
			
			_allGamers = new GamerCollection<NetworkGamer>();
			_localGamers = new GamerCollection<LocalNetworkGamer>();
//			for (int x = 0; x < Gamer.SignedInGamers.Count; x++) {
//				GamerStates states = GamerStates.Local;
//				if (x == 0)
//					states |= GamerStates.Host;
//				LocalNetworkGamer localGamer = new LocalNetworkGamer(this, (byte)x, states);
//				localGamer.SignedInGamer = Gamer.SignedInGamers[x];
//				_allGamers.AddGamer(localGamer);
//				_localGamers.AddGamer(localGamer);
//				
//				// We will attach a property change handler to local gamers
//				//  se that we can broadcast the change to other peers.
//				localGamer.PropertyChanged += HandleGamerPropertyChanged;	
//				
//			}

			_remoteGamers = new GamerCollection<NetworkGamer>();
			_previousGamers = new GamerCollection<NetworkGamer>();
			hostingGamer = null;
			
			commandQueue = new Queue<CommandEvent>();			
			
			this.sessionType = sessionType;
			this.maxGamers = maxGamers;
			this.privateGamerSlots = privateGamerSlots;
			this.sessionProperties = sessionProperties;
			this.isHost = isHost;
			this.hostGamerIndex = hostGamer;            
            if (isHost)
                networkPeer = new MonoGamerPeer(this, null);
            else
            {
                if (networkPeer == null)
                    networkPeer = new MonoGamerPeer(this, availableSession);
            }
            			
			CommandGamerJoined gj = new CommandGamerJoined(hostGamer, this.isHost, true);
			commandQueue.Enqueue(new CommandEvent(gj));
		}
Exemple #31
0
        private NetworkSession(NetworkSessionType sessionType, int maxGamers, int privateGamerSlots, NetworkSessionProperties sessionProperties, bool isHost, int hostGamer, AvailableNetworkSession availableSession)
            : this()
        {
            if (sessionProperties == null) {
                throw new ArgumentNullException ("sessionProperties");
            }

            _allGamers = new GamerCollection<NetworkGamer>();
            _localGamers = new GamerCollection<LocalNetworkGamer>();
            _remoteGamers = new GamerCollection<NetworkGamer>();
            _previousGamers = new GamerCollection<NetworkGamer>();
            hostingGamer = null;

            commandQueue = new Queue<CommandEvent>();

            this.sessionType = sessionType;
            this.maxGamers = maxGamers;
            this.privateGamerSlots = privateGamerSlots;
            this.sessionProperties = sessionProperties;
            this.isHost = isHost;
            this.hostGamerIndex = hostGamer;
            if (isHost)
                networkPeer = new MonoGamerPeer(this, null);
            else
            {
                if (networkPeer == null)
                    networkPeer = new MonoGamerPeer(this, availableSession);
            }

            CommandGamerJoined gj = new CommandGamerJoined(hostGamer, this.isHost, true);
            commandQueue.Enqueue(new CommandEvent(gj));
        }
Exemple #32
0
		private static NetworkSession JoinSession (AvailableNetworkSession availableSession) 
		{
			NetworkSession session = null;
			
			try {                
				NetworkSessionType sessionType = availableSession.SessionType;
				int maxGamers = 32;
				int privateGamerSlots = 0;
				bool isHost = false;
				int hostGamer = -1;
				NetworkSessionProperties sessionProperties = availableSession.SessionProperties;
				if (sessionProperties == null)
					sessionProperties = new NetworkSessionProperties();
				session = new NetworkSession (sessionType, maxGamers, privateGamerSlots, sessionProperties, isHost, hostGamer, availableSession);
				
			} finally {
			}
			
			return session;		
		}
Exemple #33
0
        public static NetworkSession Join(AvailableNetworkSession availableSession)
        {
            if ( availableSession == null )
                throw new ArgumentNullException();

            try
            {
                throw new NotImplementedException();
            }
            finally
            {
            }
        }
 /* Call this internally when a connection to a given available session is desired.
  */
 protected virtual void ConnectToSession(AvailableNetworkSession sess)
 {
     Trace.WriteLine("Connecting to session host: {0}", sess.HostGamertag);
       Debug.Assert(joinAsync_ == null);
       joinAsync_ = NetworkSession.BeginJoin(sess, OnSessionConnected, null);
       Debug.Assert(joinAsync_.CompletedSynchronously == false);
 }
 /// <summary>
 /// Creates a new instance
 /// </summary>
 /// <param name="availableSession">The Xbox Live AvailableNetworkSession instance</param>
 internal LiveAvailableSession(AvailableNetworkSession availableSession)
 {
     AvailableNetworkSession = availableSession;
     _sessionProperties =
         LiveSessionProperties.ConvertFromLiveSessionProperties(availableSession.SessionProperties);
 }
Exemple #36
0
 public static NetworkSession Join(AvailableNetworkSession availableSession)
 {
     throw new NotImplementedException();
 }
Exemple #37
0
 public static NetworkSession Join(AvailableNetworkSession availableSession)
 {
     throw new NotImplementedException();
 }
Exemple #38
0
 public static NetworkSession Join(AvailableNetworkSession availableSession)
 {
   return NetworkSession.EndJoin(NetworkSession.BeginJoin(availableSession, (AsyncCallback) null, (object) null));
 }
Exemple #39
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 ();
					bool isHost = im.ReadBoolean ();

					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 ();
						isHost = im.ReadBoolean ();
						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);

			}
		}
Exemple #40
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);
     }
   }
 }