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


C# NetClient.Shutdown方法代码示例

本文整理汇总了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");
		}
开发者ID:marvel54,项目名称:lidgren-network,代码行数:33,代码来源:Program.cs

示例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");
		}
开发者ID:aotis,项目名称:AngryTanks,代码行数:15,代码来源:Program.cs

示例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");
		}
开发者ID:pr0gramm3r1,项目名称:AngryTanks,代码行数:16,代码来源:Program.cs

示例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");
		}
开发者ID:pr0gramm3r1,项目名称:AngryTanks,代码行数:16,代码来源:Program.cs

示例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");
		}
开发者ID:zakvdm,项目名称:Frenetic,代码行数:18,代码来源:Program.cs

示例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");
        }
开发者ID:RainsSoft,项目名称:lidgren-network-gen3,代码行数:25,代码来源:Program.cs

示例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");
		}
开发者ID:marvel54,项目名称:lidgren-network,代码行数:101,代码来源:Program.cs

示例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");
        }
开发者ID:ComposerCookie,项目名称:TeamSmiter,代码行数:13,代码来源:Client.cs

示例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");
        }
开发者ID:cody82,项目名称:spacewar-arena,代码行数:15,代码来源:Program.cs

示例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();
        }
开发者ID:JeffM2501,项目名称:HackSharp,代码行数:88,代码来源:Program.cs


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