本文整理汇总了C#中Lidgren.Network.NetClient.Shutdown方法的典型用法代码示例。如果您正苦于以下问题:C# NetClient.Shutdown方法的具体用法?C# NetClient.Shutdown怎么用?C# NetClient.Shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lidgren.Network.NetClient
的用法示例。
在下文中一共展示了NetClient.Shutdown方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
s_mainForm = new Form1();
NetConfiguration config = new NetConfiguration("stress");
config.ThrottleBytesPerSecond = 3500;
s_client = new NetClient(config);
// 100 ms simulated roundtrip latency
s_client.SimulatedMinimumLatency = 0.1f;
// ... + 0 to 50 ms
s_client.SimulatedLatencyVariance = 0.05f;
// 10% loss (!)
// s_client.SimulatedLoss = 0.1f;
// 5% duplicated messages (!)
// s_client.SimulatedDuplicates = 0.05f;
s_readBuffer = s_client.CreateBuffer();
s_sentUntil = NetTime.Now;
s_nextDisplay = NetTime.Now;
Application.Idle += new EventHandler(OnAppIdle);
Application.Run(s_mainForm);
s_client.Shutdown("Application exiting");
}
示例2: Main
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
s_form = new Form1();
NetPeerConfiguration config = new NetPeerConfiguration("filestream");
s_client = new NetClient(config);
s_client.Start();
Application.Idle += new EventHandler(AppLoop);
Application.Run(s_form);
s_client.Shutdown("Application exiting");
}
示例3: Main
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
s_form = new Form1();
NetPeerConfiguration config = new NetPeerConfiguration("chat");
config.AutoFlushSendQueue = false;
s_client = new NetClient(config);
s_client.RegisterReceivedCallback(new SendOrPostCallback(GotMessage));
Application.Run(s_form);
s_client.Shutdown("Bye");
}
示例4: Main
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
MainForm = new Form1();
NetPeerConfiguration config = new NetPeerConfiguration("durable");
config.EnableMessageType(NetIncomingMessageType.DiscoveryResponse);
Client = new NetClient(config);
Client.Start();
Application.Idle += new EventHandler(AppLoop);
Application.Run(MainForm);
Client.Shutdown("App exiting");
}
示例5: Main
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
s_mainForm = new Form1();
NetConfiguration config = new NetConfiguration("OoBSample");
s_client = new NetClient(config);
s_client.SetMessageTypeEnabled(NetMessageType.OutOfBandData, true);
s_client.Start();
s_readBuffer = s_client.CreateBuffer();
Application.Idle += new EventHandler(OnAppIdle);
Application.Run(s_mainForm);
s_client.Shutdown("Bye");
}
示例6: Main
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
//System.Windows.Forms.ThreadExceptionDialog.CheckForIllegalCrossThreadCalls = false;
System.Windows.Forms.Control.CheckForIllegalCrossThreadCalls = false;
for (int i = 0; i < 1; i++) {
NetPeerConfiguration config = new NetPeerConfiguration("chat");
config.AutoFlushSendQueue = false;
NetClient s_client = new NetClient(config);
s_client.RegisterReceivedCallback(new SendOrPostCallback(GotMessage),new SynchronizationContext());
s_clients.Add(s_client);
}
s_form = new Form1();
s_form.Show();
while (true) {
Application.DoEvents();
foreach (var s_client in s_clients) {
}
}
//Application.Run(s_form);
foreach(var s_client in s_clients)
s_client.Shutdown("Bye");
}
示例7: Main
//.........这里部分代码省略.........
buf.Write((int)52, 7);
buf.Write("Hallon");
client.SendMessage(buf, NetChannel.ReliableInOrder1, new NetBuffer("kokos"));
}
if (client.Status == NetConnectionStatus.Disconnected)
end = NetTime.Now + 1.0; // end in one second
break;
case NetMessageType.Receipt:
events.Add("CReceipt " + clientBuffer.ReadString());
break;
case NetMessageType.ConnectionRejected:
case NetMessageType.BadMessageReceived:
throw new Exception("Failed: " + nmt);
case NetMessageType.DebugMessage:
// silently ignore
break;
default:
// ignore
Console.WriteLine("Ignored: " + nmt);
break;
}
}
//
// server
//
if (server.ReadMessage(serverBuffer, out nmt, out sender))
{
switch (nmt)
{
case NetMessageType.StatusChanged:
events.Add("SStatus " + sender.Status);
Console.WriteLine("Server: " + sender.Status + " (" + serverBuffer.ReadString() + ")");
break;
case NetMessageType.ConnectionRejected:
case NetMessageType.BadMessageReceived:
throw new Exception("Failed: " + nmt);
case NetMessageType.Data:
events.Add("DataRec " + serverBuffer.LengthBits);
bool shouldBeTrue = serverBuffer.ReadBoolean();
int shouldBeFifthTwo = serverBuffer.ReadInt32(7);
string shouldBeHallon = serverBuffer.ReadString();
if (shouldBeTrue != true ||
shouldBeFifthTwo != 52 ||
shouldBeHallon != "Hallon")
throw new Exception("Bad data transmission");
disconnect = now + 1.0;
break;
case NetMessageType.DebugMessage:
// silently ignore
break;
default:
// ignore
Console.WriteLine("Ignored: " + nmt);
break;
}
}
if (now > disconnect)
{
server.Connections[0].Disconnect("Bye", 0.1f);
disconnect = double.MaxValue;
}
}
// verify events
string[] expected = new string[] {
"CStatus Connecting",
"SStatus Connecting",
"CStatus Connected",
"SStatus Connected",
"DataRec 64",
"CReceipt kokos",
"SStatus Disconnecting",
"CStatus Disconnecting",
"SStatus Disconnected",
"CStatus Disconnected"
};
if (events.Count != expected.Length)
throw new Exception("Mismatch in events count! Expected " + expected.Length + ", got " + events.Count);
for(int i=0;i<expected.Length;i++)
{
if (events[i] != expected[i])
throw new Exception("Event " + i + " (" + expected[i] + ") mismatched!");
}
Console.WriteLine("All tests successful");
Console.ReadKey();
server.Shutdown("App exiting");
client.Shutdown("App exiting");
}
示例8: Init
// Starting up Methods
public void Init(string address, int port)
{
// Setting up setting for connections.
_config = new NetPeerConfiguration("TeamSmiterxV01");
_config.UseMessageRecycling = false;
_config.AutoFlushSendQueue = false;
// Create the Client
_client = new NetClient(_config);
_client.RegisterReceivedCallback(new SendOrPostCallback(HandleIncomingData));
_client.Shutdown("Bye");
}
示例9: Main
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
s_form = new Form1();
NetPeerConfiguration config = new NetPeerConfiguration("chat");
s_client = new NetClient(config);
Application.Idle += new EventHandler(Application_Idle);
Application.Run(s_form);
s_client.Shutdown("Bye");
}
示例10: Main
static void Main(string[] args)
{
NetConfiguration config = new NetConfiguration("durable");
NetClient client = new NetClient(config);
client.SimulatedMinimumLatency = 0.05f;
client.SimulatedLatencyVariance = 0.025f;
client.SimulatedLoss = 0.03f;
// wait half a second to allow server to start up in Visual Studio
Thread.Sleep(500);
// create a buffer to read data into
NetBuffer buffer = client.CreateBuffer();
// connect to localhost
client.Connect("localhost", 14242, Encoding.ASCII.GetBytes("Hail from client"));
// enable some library messages
client.SetMessageTypeEnabled(NetMessageType.BadMessageReceived, true);
//client.SetMessageTypeEnabled(NetMessageType.VerboseDebugMessage, true);
client.SetMessageTypeEnabled(NetMessageType.ConnectionRejected, true);
FileStream fs = new FileStream("./clientlog.txt", FileMode.Create, FileAccess.Write, FileShare.Read);
StreamWriter wrt = new StreamWriter(fs);
Output(wrt, "Log started at " + DateTime.Now);
wrt.Flush();
// create a stopwatch
Stopwatch sw = new Stopwatch();
sw.Start();
int loops = 0;
while (!Console.KeyAvailable)
{
NetMessageType type;
if (client.ReadMessage(buffer, out type))
{
switch (type)
{
case NetMessageType.StatusChanged:
if (client.ServerConnection.RemoteHailData != null)
Output(wrt, "New status: " + client.Status + " (" + buffer.ReadString() + ") Remote hail is: " + Encoding.ASCII.GetString(client.ServerConnection.RemoteHailData));
else
Output(wrt, "New status: " + client.Status + " (" + buffer.ReadString() + ") Remote hail hasn't arrived.");
break;
case NetMessageType.BadMessageReceived:
case NetMessageType.ConnectionRejected:
case NetMessageType.DebugMessage:
case NetMessageType.VerboseDebugMessage:
//
// These types of messages all contain a string in the buffer; display it.
//
Output(wrt, buffer.ReadString());
break;
case NetMessageType.Data:
default:
//
// For this application; server doesn't send any data... so Data messages are unhandled
//
Output(wrt, "Unhandled: " + type + " " + buffer.ToString());
break;
}
}
// send a message every second
if (client.Status == NetConnectionStatus.Connected && sw.Elapsed.TotalMilliseconds >= 516)
{
loops++;
//Console.WriteLine("Sending message #" + loops);
Console.Title = "Client; Messages sent: " + loops;
Output(wrt, "Sending #" + loops + " at " + NetTime.ToMillis(NetTime.Now));
NetBuffer send = client.CreateBuffer();
send.Write("Message #" + loops);
client.SendMessage(send, NetChannel.ReliableInOrder14);
sw.Reset();
sw.Start();
}
Thread.Sleep(1);
}
// clean shutdown
client.Shutdown("Application exiting");
wrt.Close();
}