本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
}