Пример #1
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);
        }
Пример #2
0
        public static IAsyncResult BeginFind(
            NetworkSessionType sessionType,
            IEnumerable <SignedInGamer> localGamers,
            NetworkSessionProperties searchProperties,
            AsyncCallback callback,
            object asyncState
            )
        {
            if (sessionType == NetworkSessionType.Local)
            {
                throw new ArgumentException("sessionType");
            }
            if (activeAction != null || activeSession != null)
            {
                throw new InvalidOperationException();
            }

            int locals = 0;

            foreach (SignedInGamer gamer in localGamers)
            {
                locals += 1;
            }

            activeAction = new NetworkSessionAction(
                asyncState,
                callback,
                locals,
                localGamers,
                0,
                searchProperties,
                sessionType
                );
            return(activeAction);
        }
Пример #3
0
        public static IAsyncResult BeginFind(
            NetworkSessionType sessionType,
            int maxLocalGamers,
            NetworkSessionProperties searchProperties,
            AsyncCallback callback,
            object asyncState
            )
        {
            if (sessionType == NetworkSessionType.Local)
            {
                throw new ArgumentException("sessionType");
            }
            if (maxLocalGamers < 1 || maxLocalGamers > 4)
            {
                throw new ArgumentOutOfRangeException("maxLocalGamers");
            }
            if (activeAction != null || activeSession != null)
            {
                throw new InvalidOperationException();
            }

            activeAction = new NetworkSessionAction(
                asyncState,
                callback,
                maxLocalGamers,
                null,
                0,
                searchProperties,
                sessionType
                );
            return(activeAction);
        }
Пример #4
0
        public static IAsyncResult BeginCreate(
            NetworkSessionType sessionType,
            IEnumerable <SignedInGamer> localGamers,
            int maxGamers,
            int privateGamerSlots,
            NetworkSessionProperties sessionProperties,
            AsyncCallback callback,
            object asyncState
            )
        {
            if (privateGamerSlots < 0 || privateGamerSlots > maxGamers)
            {
                throw new ArgumentOutOfRangeException("privateGamerSlots");
            }
            if (activeAction != null || activeSession != null)
            {
                throw new InvalidOperationException();
            }

            activeAction = new NetworkSessionAction(
                asyncState,
                callback,
                0,
                localGamers,
                privateGamerSlots,
                sessionProperties,
                sessionType
                );
            return(activeAction);
        }
Пример #5
0
        public static IAsyncResult BeginJoinInvited(
            int maxLocalGamers,
            AsyncCallback callback,
            object asyncState
            )
        {
            if (maxLocalGamers < 1 || maxLocalGamers > 4)
            {
                throw new ArgumentOutOfRangeException("maxLocalGamers");
            }
            if (activeAction != null || activeSession != null)
            {
                throw new InvalidOperationException();
            }

            activeAction = new NetworkSessionAction(
                asyncState,
                callback,
                maxLocalGamers,
                null,
                0,
                null,
                NetworkSessionType.PlayerMatch                 // FIXME
                );
            return(activeAction);
        }
Пример #6
0
        public static AvailableNetworkSessionCollection EndFind(IAsyncResult result)
        {
            if (result != activeAction)
            {
                throw new ArgumentException("result");
            }

            List <AvailableNetworkSession> sessions = new List <AvailableNetworkSession>();

            activeAction = null;
            return(new AvailableNetworkSessionCollection(sessions));
        }
Пример #7
0
        public static NetworkSession EndCreate(IAsyncResult result)
        {
            if (result != activeAction)
            {
                throw new ArgumentException("result");
            }

            activeSession = new NetworkSession(
                activeAction.SessionProperties,
                activeAction.SessionType,
                69,
                activeAction.MaxPrivateSlots,
                activeAction.MaxLocalGamers,
                activeAction.LocalGamers
                );

            activeAction = null;
            return(activeSession);
        }
Пример #8
0
        public static NetworkSession EndJoin(IAsyncResult result)
        {
            if (result != activeAction)
            {
                throw new ArgumentException("result");
            }

            int actionMaxLocalGamers = activeAction.MaxLocalGamers;
            IEnumerable <SignedInGamer> actionLocalGamers = activeAction.LocalGamers;

            activeAction = null;

            activeSession = new NetworkSession(
                null,                           // FIXME
                NetworkSessionType.PlayerMatch, // FIXME
                MaxSupportedGamers,             // FIXME
                4,                              // FIXME
                actionMaxLocalGamers,
                actionLocalGamers
                );
            return(activeSession);
        }
Пример #9
0
        public static IAsyncResult BeginJoinInvited(
            IEnumerable <SignedInGamer> localGamers,
            AsyncCallback callback,
            object asyncState
            )
        {
            if (activeAction != null || activeSession != null)
            {
                throw new InvalidOperationException();
            }

            activeAction = new NetworkSessionAction(
                asyncState,
                callback,
                0,
                localGamers,
                0,
                null,
                NetworkSessionType.PlayerMatch                 // FIXME
                );
            return(activeAction);
        }