BeginFind() static private method

static private BeginFind ( SessionType sessionType, int maxLocalPlayers, SessionProperties sessionProperties, AsyncCallback callback, object asyncState ) : IAsyncResult
sessionType SessionType
maxLocalPlayers int
sessionProperties SessionProperties
callback AsyncCallback
asyncState object
return IAsyncResult
Beispiel #1
0
        /// <summary>
        /// Sends a Find query on the network interface to look for AvailableSession instances asynchrnously
        /// </summary>
        /// <param name="sessionType">The SessionType we're looking for</param>
        /// <param name="maxLocalPlayers">The Maximum local players that can be added to the session used to filter sessions that have a limited number of opened public slots</param>
        /// <param name="sessionProperties">The SessionProperties that will be used to filter query results. Can be null</param>
        public override void FindSessions(SessionType sessionType, int maxLocalPlayers, SessionProperties sessionProperties)
        {
            if (CurrentSession != null)
            {
                throw new CoreException("Session is already running");
            }

            _networkSessionLocker = FindingSessions;
            LidgrenSession.BeginFind(sessionType, maxLocalPlayers, sessionProperties, OnLidgrenSessionsFound, _networkSessionLocker);
        }
        /// <summary>
        /// Sends a Find query on the network interface to look for AvailableSession instances asynchrnously
        /// </summary>
        /// <param name="sessionType">The SessionType we're looking for</param>
        /// <param name="maxLocalPlayers">The Maximum local players that can be added to the session used to filter sessions that have a limited number of opened public slots</param>
        /// <param name="sessionProperties">The SessionProperties that will be used to filter query results. Can be null</param>
        public override void FindSessions(SessionType sessionType, int maxLocalPlayers, SessionProperties sessionProperties)
        {
            if (CurrentSession != null)
            {
                throw new CoreException("Session is already running");
            }

            if (sessionType == SessionType.WideAreaNetwork)
            {
                throw new NotImplementedException("Use FindSessionsWan method instead");
            }

            // Create a temporary session to listen for discovery messages
            CurrentSession = new LidgrenSession(sessionType, maxLocalPlayers, 0, sessionProperties);

            _networkSessionLocker = FindingSessions;
            LidgrenSession.BeginFind(sessionType, maxLocalPlayers, sessionProperties, OnLidgrenSessionsFound, _networkSessionLocker);
        }