/// <summary> /// Destroys the instance of <see cref="WakeServer" />. /// </summary> /// <param name="server">NetServer to destroy</param> /// <returns><c>true</c>, if server was destroyed, <c>false</c> otherwise.</returns> public static void DestroyServer(WakeServer server) { if (_servers.Contains(server) == false) { Log(WakeError.ServerNotExists); return; } server.DisconnectAllClients(); RemoveSocket(server.Socket); _servers.Remove(server); }
/// <summary> /// Initializes a new instance of the <see cref="WakeServer" /> class. We can simulate real world network conditions by /// using the simMinTimeout/simMaxTimeout params /// to simulate connection lag. /// </summary> /// <returns>The server object.</returns> /// <param name="maxConnections">Max connections.</param> /// <param name="port">Port.</param> /// <param name="simMinLatency">Minimum latency to simulate on the server.</param> /// <param name="simMaxLatency">Maximum latency to simulate on the server.</param> public static WakeServer CreateServer(int maxConnections, int port, int simMinLatency = 0, int simMaxLatency = 0) { if (!Initialized) { Log(WakeError.NotInitialized); return(null); } var server = new WakeServer(maxConnections, port, simMinLatency, simMaxLatency); // If we were successful in creating our server and it is unique if (server.IsConnected && !_servers.Contains(server)) { _servers.Add(server); return(server); } RemoveSocket(server.Socket); return(server); }