private void FrmSharer_FormClosing(object sender, FormClosingEventArgs e) { if (shareDesktop) { tcpServer.Stop(); } }
public static void KeyHandler(object a, CommandArgs e) { string input = e.Message; if (String.Equals(input, "stop", StringComparison.CurrentCultureIgnoreCase)) { server.Stop(); } else if (String.Equals(input, "clear", StringComparison.CurrentCultureIgnoreCase)) { Console.Clear(); server.Start(); } else { try { mapArray = loader.GetMapCharArray(input); newMap1 = true; newMap2 = true; mapName = input; mapNumber = Convert.ToInt32(input.Replace("level", "")); writer.Custom("[SERVER] Sending map '" + input + "' to clients.", Color.Green); server.Start(); } catch { writer.Custom("[SERVER] [ERROR] Could not find map '" + input + "'.", Color.DarkRed); server.Start(); } } }
static void Main(string[] args) { Console.WriteLine("输入监听ip:"); string ip = Console.ReadLine(); myTcpServer = new AsyncTCPServer(IPAddress.Parse(ip), 3000); //禁止关闭按钮 Util.DisableCloseButton(Console.Title); #region 事件注册 myTcpServer.ClientConnected += MyTcpServer_ClientConnected; myTcpServer.DataReceived += MyTcpServer_DataReceived; myTcpServer.CompletedSend += MyTcpServer_CompletedSend; myTcpServer.ClientDisconnected += MyTcpServer_ClientDisconnected; #endregion myTcpServer.Start(); Console.WriteLine("服务器已经启动,正在监听中....."); while (true) //程序停在这里 { string arg = Console.ReadLine(); if (arg == "exit") { break; } } myTcpServer.CloseAllClient(); myTcpServer.Stop(); Console.WriteLine("任务已经结束,按回车退出程序..."); Console.ReadLine(); }
public void StopListen() { _tcpListener.Stop(); }
public void Stop() { m_Server.Stop(); IsStoped = true; }