static public int Disconnect(IntPtr l) { try { TcpServer self = (TcpServer)checkSelf(l); self.Disconnect(); pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public bool Disconnect(IntPtr dwConnId, bool force = true) { return(server.Disconnect(dwConnId, force)); }
public void Run(ushort port, bool autoStart = true) { if (!flagStart) { _server.OnStart += _OnStart; } if (!flagConnect) { _server.OnConnect += _OnConnect; } if (!flagData) { _server.OnData += _OnData; } if (!flagDisconnect) { _server.OnDisconnect += _OnDisconnect; } if (!flagStop) { _server.OnStop += _OnStop; } bool isAlive = true; while (isAlive) { var input = autoStart ? "start" : Console.ReadLine(); var blocks = input.Split(' '); switch (blocks[0]) { default: logger.Log("commands: isListening / start / send <ipep> <message> / disconnect <ipep> / stop / exit"); break; case "start": _server.Start(new IPEndPoint(IPAddress.Any, port)); break; case "isListening": logger.Log(_server.IsListening ? "server listening" : "server not listening"); break; case "send": { if (blocks.Length < 3) { logger.Log("usage: send <ipep> <message>"); } else { var ipep = blocks[1].ToIPEP(); if (ipep == null) { logger.Log("bad ipendpoint"); } else { var message = input.Substring(("send " + blocks[1] + " ").Length); _server.Send(ipep, Encoding.UTF8.GetBytes(message)); } } } break; case "disconnect": _server.Disconnect(blocks[1].ToIPEP()); break; case "stop": _server.Stop(); break; case "exit": { if (_server.IsListening) { _server.Stop(); } isAlive = false; } break; } if (autoStart) { autoStart = false; } } }
private void Disconnect() { _tcpServer.Disconnect(); }
public bool Disconnect(uint connId, bool force = true) { return(server.Disconnect(connId, force)); }