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


C# NetClient.Recycle方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            NetPeerConfiguration config = new NetPeerConfiguration("LidgrenTestServer");
            config.AutoFlushSendQueue = false;
            var s_client = new NetClient(config);

            s_client.Start();
            NetOutgoingMessage hail = s_client.CreateMessage("This is the hail message");
            s_client.Connect("localhost", 14242, hail);

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

示例2: DispatchIM

		/// <summary>
		/// 
		/// </summary>
		/// <param name="message"></param>
		void DispatchIM ( NetClient client )
		{
			NetIncomingMessage msg;
			while ((msg = client.ReadMessage()) != null)
			{
				switch (msg.MessageType)
				{
					case NetIncomingMessageType.VerboseDebugMessage:Log.Debug	("UI Net: " + msg.ReadString()); break;
					case NetIncomingMessageType.DebugMessage:		Log.Verbose	("UI Net: " + msg.ReadString()); break;
					case NetIncomingMessageType.WarningMessage:		Log.Warning	("UI Net: " + msg.ReadString()); break;
					case NetIncomingMessageType.ErrorMessage:		Log.Error	("UI Net: " + msg.ReadString()); break;

					case NetIncomingMessageType.DiscoveryResponse:
						DiscoveryResponse( msg.SenderEndPoint, msg.ReadString() );
						break;

					//case NetIncomingMessageType.StatusChanged:		

					//	var status	=	(NetConnectionStatus)msg.ReadByte();
					//	var message	=	msg.ReadString();
					//	Log.Message("UI: {0} - {1}", status, message );

					//	break;
					
					//case NetIncomingMessageType.Data:
						
					//	var netCmd	=	(NetCommand)msg.ReadByte();
					//	state.DataReceived( netCmd, msg );

					//	break;
					
					default:
						Log.Warning("CL: Unhandled type: " + msg.MessageType);
						break;
				}
				client.Recycle(msg);
			}			
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:42,代码来源:UserInterface.Internal.cs

示例3: DispatchIM

		/// <summary>
		/// 
		/// </summary>
		/// <param name="message"></param>
		void DispatchIM ( NetClient client )
		{
			NetIncomingMessage msg;
			while ((msg = client.ReadMessage()) != null)
			{
				switch (msg.MessageType)
				{
					case NetIncomingMessageType.VerboseDebugMessage:Log.Debug	("CL Net: " + msg.ReadString()); break;
					case NetIncomingMessageType.DebugMessage:		Log.Verbose	("CL Net: " + msg.ReadString()); break;
					case NetIncomingMessageType.WarningMessage:		Log.Warning	("CL Net: " + msg.ReadString()); break;
					case NetIncomingMessageType.ErrorMessage:		Log.Error	("CL Net: " + msg.ReadString()); break;

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

					case NetIncomingMessageType.StatusChanged:		

						var status	=	(NetConnectionStatus)msg.ReadByte();
						var message	=	msg.ReadString();
						Log.Message("CL: {0} - {1}", status, message );

						state.StatusChanged( status, message, msg.SenderConnection );

						break;
					
					case NetIncomingMessageType.Data:
						
						var netCmd	=	(NetCommand)msg.ReadByte();
						state.DataReceived( netCmd, msg );

						break;
					
					default:
						Log.Warning("CL: Unhandled type: " + msg.MessageType);
						break;
				}
				client.Recycle(msg);
			}			
		}
开发者ID:demiurghg,项目名称:FusionEngine,代码行数:47,代码来源:GameClient.Internal.cs


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