• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# NetworkSessionType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中NetworkSessionType的典型用法代码示例。如果您正苦于以下问题:C# NetworkSessionType类的具体用法?C# NetworkSessionType怎么用?C# NetworkSessionType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NetworkSessionType类属于命名空间,在下文中一共展示了NetworkSessionType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CreateOrFindSessionScreen

        //Audio audioHelper, Cue mystery)
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public CreateOrFindSessionScreen(ScreenManager screenManager, NetworkSessionType sessionType, AudioManager audioManager)
            : base(GetMenuTitle(sessionType), false)
        {
            networkHelper = new NetworkHelper();
            networkInterface = new NetworkInterface();
            networkInterface.InitNetwork(screenManager.Game);
            this.audioManager = audioManager;
            //this.audioHelper = audioHelper;
            //this.mystery = mystery;
            this.sessionType = sessionType;

            // Create our menu entries.
            MenuEntry createSessionMenuEntry = new MenuEntry(Resources.CreateSession);
            MenuEntry findSessionsMenuEntry = new MenuEntry(Resources.FindSessions);
            MenuEntry backMenuEntry = new MenuEntry(Resources.Back);

            // Hook up menu event handlers.
            createSessionMenuEntry.Selected += CreateSessionMenuEntrySelected;
            findSessionsMenuEntry.Selected += FindSessionsMenuEntrySelected;
            backMenuEntry.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(createSessionMenuEntry);
            MenuEntries.Add(findSessionsMenuEntry);
            MenuEntries.Add(backMenuEntry);
        }
开发者ID:bradleat,项目名称:trafps,代码行数:30,代码来源:CreateOrFindSessionScreen.cs


示例2: FindSession

        public void FindSession(NetworkSessionType sessionType, int maxLocalPlayers, NetworkSessionProperties properties)
        {
            // all sessions found
            AvailableNetworkSessionCollection availableSessions;
            // The session we'll join
            AvailableNetworkSession availableSession = null;

            availableSessions = NetworkSession.Find(sessionType, maxLocalPlayers, properties);

            // Get a session with available gamer slots
            foreach (AvailableNetworkSession  curSession in availableSessions)
            {
                int TotalSessionSlots = curSession.OpenPublicGamerSlots + curSession.OpenPrivateGamerSlots;
                if (TotalSessionSlots > curSession.CurrentGamerCount)
                {
                    availableSession = curSession;
                }
            }

            // if a session was found, connect to it
            if (availableSession != null)
            {
                networkHelper.session = NetworkSession.Join(availableSession);
            }
        }
开发者ID:bradleat,项目名称:trafps,代码行数:25,代码来源:Session.cs


示例3: SearchResultsScreen

        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        /// <param name="sessionType">The type of session searched for.</param>
        public SearchResultsScreen(NetworkSessionType sessionType) : base()
        {
            // apply the parameters
            this.sessionType = sessionType;

            // set the transition times
            TransitionOnTime = TimeSpan.FromSeconds(1.0);
            TransitionOffTime = TimeSpan.FromSeconds(0.0);
        }
开发者ID:Nailz,项目名称:MonoGame-Samples,代码行数:13,代码来源:SearchResultsScreen.cs


示例4: SearchResultsScreen

        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        /// <param name="sessionType">The type of session searched for.</param>
        public SearchResultsScreen(NetworkSessionType sessionType)
            : base(new Viewport(), null, null)
        {
            throw new NotImplementedException();
            // apply the parameters
            this.sessionType = sessionType;

            // set the transition times
            TransitionOnTime = TimeSpan.FromSeconds(1.0);
            TransitionOffTime = TimeSpan.FromSeconds(0.0);
        }
开发者ID:zakvdm,项目名称:Frenetic,代码行数:15,代码来源:SearchResultsScreen.cs


示例5: GetMenuTitle

		/// <summary>
		/// Helper chooses an appropriate menu title for the specified session type.
		/// </summary>
		static string GetMenuTitle (NetworkSessionType sessionType)
		{
			switch (sessionType) {
			case NetworkSessionType.PlayerMatch:
				return Resources.PlayerMatch;

			case NetworkSessionType.SystemLink:
				return Resources.SystemLink;

			default:
				throw new NotSupportedException ();
			}
		}
开发者ID:Nailz,项目名称:MonoGame-Samples,代码行数:16,代码来源:CreateOrFindSessionScreen.cs


示例6: ChooseGamers

        /// <summary>
        /// Decides which local gamer profiles should be included in a network session.
        /// This is passed the index of the primary gamer (the profile who selected the
        /// relevant menu option, or who is responding to an invite). The primary gamer
        /// will always be included in the session. Other gamers may also be added if
        /// there are suitable profiles signed in. To control how many gamers can be
        /// returned by this method, adjust the MaxLocalGamers constant.
        /// </summary>
        public static IEnumerable<SignedInGamer> ChooseGamers(
                                                        NetworkSessionType sessionType,
                                                        PlayerIndex playerIndex)
        {
            List<SignedInGamer> gamers = new List<SignedInGamer>();

            // Look up the primary gamer, and make sure they are signed in.
            SignedInGamer primaryGamer = Gamer.SignedInGamers[playerIndex];

            if (primaryGamer == null)
                throw new GamerPrivilegeException();

            gamers.Add(primaryGamer);

            // Check whether any other profiles should also be included.
            foreach (SignedInGamer gamer in Gamer.SignedInGamers)
            {
                // Never include more profiles than the MaxLocalGamers constant.
                if (gamers.Count >= MaxLocalGamers)
                    break;

                // Don't want two copies of the primary gamer!
                if (gamer == primaryGamer)
                    continue;

                // If this is an online session, make sure the profile is signed
                // in to Live, and that it has the privilege for online gameplay.
                if (IsOnlineSessionType(sessionType))
                {
                    if (!gamer.IsSignedInToLive)
                        continue;

                    if (!gamer.Privileges.AllowOnlineSessions)
                        continue;
                }

                if (primaryGamer.IsGuest && !gamer.IsGuest && gamers[0] == primaryGamer)
                {
                    // Special case: if the primary gamer is a guest profile,
                    // we should insert some other non-guest at the start of the
                    // output list, because guests aren't allowed to host sessions.
                    gamers.Insert(0, gamer);
                }
                else
                {
                    gamers.Add(gamer);
                }
            }

            return gamers;
        }
开发者ID:alittle1234,项目名称:XNA_Project,代码行数:59,代码来源:NetworkSessionComponent.cs


示例7: CreateSession

        public void CreateSession(NetworkSessionType sessionType, int maxLocalPlayers, int maxGamers, 
            int privateSlots, NetworkSessionProperties properties)
        {
            if (networkHelper.session == null)
            {
                networkHelper.session = NetworkSession.Create(sessionType, maxLocalPlayers,
                    maxGamers, privateSlots, properties);

                // If the host goes out, another machine will asume as a new host
                networkHelper.session.AllowHostMigration = true;
                // Allow players to join a game in progress
                networkHelper.session.AllowJoinInProgress = true;

                eventHandler.HookSessionEvents();
            }
        }
开发者ID:bradleat,项目名称:trafps,代码行数:16,代码来源:Session.cs


示例8: CreateOrFindSession

        /// <summary>
        /// Helper method shared by the Live and System Link menu event handlers.
        /// </summary>
        void CreateOrFindSession(NetworkSessionType sessionType,
                                 PlayerIndex playerIndex)
        {
            // First, we need to make sure a suitable gamer profile is signed in.
            ProfileSignInScreen profileSignIn = new ProfileSignInScreen(sessionType);

            // Hook up an event so once the ProfileSignInScreen is happy,
            // it will activate the CreateOrFindSessionScreen.
            profileSignIn.ProfileSignedIn += delegate
            {
                GameScreen createOrFind = new CreateOrFindSessionScreen(sessionType);

                ScreenManager.AddScreen(createOrFind, playerIndex);
            };

            // Activate the ProfileSignInScreen.
            ScreenManager.AddScreen(profileSignIn, playerIndex);
        }
开发者ID:smanoharan,项目名称:242TopGearElectrified,代码行数:21,代码来源:MainMenuScreen.cs


示例9: CreateOrFindSessionScreen

        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public CreateOrFindSessionScreen(NetworkSessionType sessionType)
            : base(GetMenuTitle(sessionType))
        {
            this.sessionType = sessionType;

            // Create our menu entries.
            MenuEntry createSessionMenuEntry = new MenuEntry(Resources.CreateSession);
            MenuEntry findSessionsMenuEntry = new MenuEntry(Resources.FindSessions);
            MenuEntry backMenuEntry = new MenuEntry(Resources.Back);

            // Hook up menu event handlers.
            createSessionMenuEntry.Selected += CreateSessionMenuEntrySelected;
            findSessionsMenuEntry.Selected += FindSessionsMenuEntrySelected;
            backMenuEntry.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(createSessionMenuEntry);
            MenuEntries.Add(findSessionsMenuEntry);
            MenuEntries.Add(backMenuEntry);
        }
开发者ID:alittle1234,项目名称:XNA_Project,代码行数:23,代码来源:CreateOrFindSessionScreen.cs


示例10: CreateNetwork

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        public IAsyncResult CreateNetwork(Game game, NetworkSessionType sessionType, int maxLocalGamers, int maxGamers, int privateGamerSlots, NetworkSessionProperties sessionProperties, bool AllowHostMigration, bool AllowJoinInProgress)
        {
            SessionManager sessionManager = new SessionManager(game);

            IAsyncResult asyncResult = sessionManager.CreateSession(sessionType, maxLocalGamers, maxGamers, privateGamerSlots, sessionProperties);
            /*
            if (networkHelper.NetworkGameSession != null)
            {
                if (AllowHostMigration == true)
                    networkHelper.NetworkGameSession.AllowHostMigration = true;

                if (AllowJoinInProgress == true)
                    networkHelper.NetworkGameSession.AllowJoinInProgress = true;
                return asyncResult;
            }
            else
            {
                //throw new Exception("Session was not Created");
                return asyncResult;

            }*/
            return asyncResult;
        }
开发者ID:bradleat,项目名称:trafps,代码行数:27,代码来源:NetworkInterface.cs


示例11: Create

		public static NetworkSession Create (
         NetworkSessionType sessionType,			// Type of session being hosted.
         IEnumerable<SignedInGamer> localGamers,	// Maximum number of local players on the same gaming machine in this network session.
         int maxGamers,								// Maximum number of players allowed in this network session.  For Zune-based games, this value must be between 2 and 8; 8 is the maximum number of players supported in the session.
         int privateGamerSlots,						// Number of reserved private session slots created for the session. This value must be less than maximumGamers. 
         NetworkSessionProperties sessionProperties // Properties of the session being created.
		)
		{
			try
			{
				if ( maxGamers < 2 || maxGamers > 8 ) 
					throw new ArgumentOutOfRangeException( "Maximum number of gamers must be between 2 and 8."  );
				if ( privateGamerSlots < 0 || privateGamerSlots > maxGamers ) 
					throw new ArgumentOutOfRangeException( "Private session slots must be between 0 and maximum number of gamers."  );
			
				networkSessionType = sessionType;
			
				throw new NotImplementedException();
			}
			finally
			{
			}
		} 
开发者ID:HaKDMoDz,项目名称:Zazumo,代码行数:23,代码来源:NetworkSession.cs


示例12: Find

 public static AvailableNetworkSessionCollection Find(NetworkSessionType sessionType, int maxLocalGamers, NetworkSessionProperties searchProperties)
 {
     throw new NotImplementedException();
 }
开发者ID:sergios1234,项目名称:monoxna,代码行数:4,代码来源:NetworkSession.cs


示例13: BeginCreate

 public static IAsyncResult BeginCreate(NetworkSessionType sessionType, int maxLocalGamers, int maxGamers, int privateGamerSlots, NetworkSessionProperties sessionProperties, AsyncCallback callback, object asyncState)
 {
     throw new NotImplementedException();
 }
开发者ID:sergios1234,项目名称:monoxna,代码行数:4,代码来源:NetworkSession.cs


示例14: BeginFind

 public static IAsyncResult BeginFind(NetworkSessionType sessionType, IEnumerable<SignedInGamer> localGamers, NetworkSessionProperties searchProperties, AsyncCallback callback, object asyncState)
 {
   int hostingGamerIndex = NetworkSession.GetHostingGamerIndex(localGamers);
   return NetworkSession.BeginFind(sessionType, hostingGamerIndex, 4, searchProperties, callback, asyncState);
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:5,代码来源:NetworkSession.cs


示例15: JoinSession

		/// <summary>
		/// Joins an existing network session.
		/// </summary>
		void JoinSession (NetworkSessionType type)
		{
			DrawMessage ("Joining session...");

			try {
				// Search for sessions.
				using (AvailableNetworkSessionCollection availableSessions =
				NetworkSession.Find (type, 
						maxLocalGamers, null)) {
					if (availableSessions.Count == 0) {
						errorMessage = "No network sessions found.";
						return;
					}

					// Join the first session we found.
					networkSession = NetworkSession.Join (availableSessions [0]);

					HookSessionEvents ();
				}
			} catch (Exception e) {
				errorMessage = e.Message;
			}
		}
开发者ID:Nailz,项目名称:MonoGame-Samples,代码行数:26,代码来源:PeerToPeerGame.cs


示例16: Find

 public static AvailableNetworkSessionCollection Find(NetworkSessionType sessionType, IEnumerable<SignedInGamer> localGamers, NetworkSessionProperties searchProperties)
 {
   int hostingGamerIndex = NetworkSession.GetHostingGamerIndex(localGamers);
   return NetworkSession.EndFind(NetworkSession.BeginFind(sessionType, hostingGamerIndex, 4, searchProperties, (AsyncCallback) null, (object) null));
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:5,代码来源:NetworkSession.cs


示例17: FindSession

        /// <summary>
        /// Start searching for a session of the given type.
        /// </summary>
        /// <param name="sessionType">The type of session to look for.</param>
        void FindSession(NetworkSessionType sessionType)
        {
            throw new System.NotImplementedException(); // TODO: delete if not gonna use
            // create the new screen
            /*
            SearchResultsScreen searchResultsScreen =
               new SearchResultsScreen(sessionType);
            searchResultsScreen.ScreenManager = this.ScreenManager;
            ScreenManager.AddScreen(searchResultsScreen);

            // start the search
            try
            {
                IAsyncResult asyncResult = Microsoft.Xna.Framework.Net.NetworkSession.BeginFind(sessionType, 1, null,
                    null, null);

                // create the busy screen
                NetworkBusyScreen busyScreen = new NetworkBusyScreen(
                    "Searching for a session...", asyncResult);
                busyScreen.OperationCompleted += searchResultsScreen.SessionsFound;
                ScreenManager.AddScreen(busyScreen);
            }
            catch (NetworkException ne)
            {
                const string message = "Failed searching for the session.";
                MessageBoxScreen messageBox = new MessageBoxScreen(message);
                messageBox.Accepted += FailedMessageBox;
                messageBox.Cancelled += FailedMessageBox;
                ScreenManager.AddScreen(messageBox);

                System.Console.WriteLine("Failed to search for session:  " +
                    ne.Message);
            }
            catch (GamerPrivilegeException gpe)
            {
                const string message =
                    "You do not have permission to search for a session.";
                MessageBoxScreen messageBox = new MessageBoxScreen(message);
                messageBox.Accepted += FailedMessageBox;
                messageBox.Cancelled += FailedMessageBox;
                ScreenManager.AddScreen(messageBox);

                System.Console.WriteLine(
                    "Insufficient privilege to search for session:  " + gpe.Message);
            }
             */
        }
开发者ID:zakvdm,项目名称:Frenetic,代码行数:51,代码来源:MainMenuScreen.cs


示例18: BeginFindSessions

 public static void BeginFindSessions(NetworkSessionType networkSessionType, int p, FindSessionCompleteHandler callback)
 {
     IAsyncResult asyncResult = NetworkSession.BeginFind(networkSessionType,
                                       p,
                                       null, new AsyncCallback(FindSessionsComplete), callback);
 }
开发者ID:schminitz,项目名称:IceCreamXNA,代码行数:6,代码来源:SceneManager.cs


示例19: ProfileSignInScreen

        /// <summary>
        /// Constructs a new profile sign in screen.
        /// </summary>
        public ProfileSignInScreen(NetworkSessionType sessionType)
        {
            this.sessionType = sessionType;

            IsPopup = true;
        }
开发者ID:bradleat,项目名称:trafps,代码行数:9,代码来源:ProfileSignInScreen.cs


示例20: Create

 public static NetworkSession Create(NetworkSessionType sessionType, int maxLocalGamers, int maxGamers, int privateGamerSlots, NetworkSessionProperties sessionProperties)
 {
     throw new NotImplementedException();
 }
开发者ID:sergios1234,项目名称:monoxna,代码行数:4,代码来源:NetworkSession.cs



注:本文中的NetworkSessionType类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NetworkStream类代码示例发布时间:2022-05-24
下一篇:
C# NetworkReader类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap