当前位置: 首页>>代码示例>>C#>>正文


C# NetServer.Recycle方法代码示例

本文整理汇总了C#中Lidgren.Network.NetServer.Recycle方法的典型用法代码示例。如果您正苦于以下问题:C# NetServer.Recycle方法的具体用法?C# NetServer.Recycle怎么用?C# NetServer.Recycle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lidgren.Network.NetServer的用法示例。


在下文中一共展示了NetServer.Recycle方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Main

        static void Main(string[] args)
        {
            NetPeerConfiguration config = new NetPeerConfiguration("LidgrenTestServer");
            config.Port = 14242;
            config.MaximumConnections = 200;

            NetServer server = new NetServer(config);

            server.Start();

            NetIncomingMessage msg;
            while(true)
            {
                if((msg = server.ReadMessage()) != null)
                {
                    Console.WriteLine(msg.ReadString());
                    server.Recycle(msg);
                }
                Thread.Sleep(20);
            }
        }
开发者ID:anthrich,项目名称:LidgrenTest,代码行数:21,代码来源:Program.cs

示例2: DispatchIM

		/// <summary>
		/// 
		/// </summary>
		/// <param name="message"></param>
		void DispatchIM ( GameTime gameTime, SnapshotQueue queue, NetServer server )
		{
			NetIncomingMessage msg;
			while ((msg = server.ReadMessage()) != null)
			{
				switch (msg.MessageType)
				{
					case NetIncomingMessageType.VerboseDebugMessage:Log.Debug	("SV Net: " + msg.ReadString()); break;
					case NetIncomingMessageType.DebugMessage:		Log.Verbose	("SV Net: " + msg.ReadString()); break;
					case NetIncomingMessageType.WarningMessage:		Log.Warning	("SV Net: " + msg.ReadString()); break;
					case NetIncomingMessageType.ErrorMessage:		Log.Error	("SV Net: " + msg.ReadString()); break;

					case NetIncomingMessageType.ConnectionLatencyUpdated:
						if (Game.Network.ShowLatency) {
							float latency = msg.ReadFloat();
							Log.Verbose("...SV ping - {0} {1,6:0.00} ms", msg.SenderEndPoint, (latency*1000) );
						}

						break;

					case NetIncomingMessageType.DiscoveryRequest:
						Log.Message("Discovery request from {0}", msg.SenderEndPoint.ToString() );
						var response = server.CreateMessage( ServerInfo() );
						server.SendDiscoveryResponse( response, msg.SenderEndPoint );

						break;

					case NetIncomingMessageType.ConnectionApproval:
						
						var userGuid	=	msg.SenderConnection.GetHailGuid();
						var userInfo	=	msg.SenderConnection.GetHailUserInfo();
						var reason		=	"";
						var approve		=	ApproveClient( userGuid, userInfo, out reason );

						if (approve) {	
							msg.SenderConnection.Approve( server.CreateMessage( ServerInfo() ) );
						} else {
							msg.SenderConnection.Deny( reason );
						}

						break;

					case NetIncomingMessageType.StatusChanged:		
						DispatchStatusChange( msg );
						break;
					
					case NetIncomingMessageType.Data:
						DispatchDataIM( gameTime, queue, msg );
						break;
					
					default:
						Log.Warning("SV: Unhandled type: " + msg.MessageType);
						break;
				}
				server.Recycle(msg);
			}		
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:61,代码来源:GameServer.Internal.cs


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