///////////////////////////////////////////////////////////////////// // CONSTRUCTORS ///////////////////////////////////////////////////////////////////// /// <summary> /// Constructs a server description for use as an announce packet. /// </summary> /// <param name="server">Server being announced</param> /// <exception cref="ArgumentNullException" /> internal ServerDescription(Server server) { if (server == null) { throw new ArgumentNullException("server", "server cannot be null"); } id = server.ID; clientCount = server.ClientCount; maxClients = server.MaxClients; requiresPassword = server.RequiresPassword; port = server.Port; name = server.Name ?? ""; temporaryDocument = (server.FilePath ?? "").Length == 0; endPoint = null; lastUpdateTimer = null; lastPingTimer = null; }
/// <summary> /// Reconstructs server description from an announce packet. /// </summary> /// <param name="listenEndpoint">Endpoint of the sender (listen server, NOT the announce source)</param> /// <param name="packet">Packet that was sent</param> /// <exception cref="ArgumentNullException" /> internal ServerDescription(IPEndPoint listenEndpoint, ServerDescription packet) { if (listenEndpoint == null) { throw new ArgumentNullException("listenEndpoint", "listenEndpoint cannot be null"); } if (packet == null) { throw new ArgumentNullException("packet", "packet cannot be null"); } id = packet.ID; clientCount = packet.ClientCount; maxClients = packet.MaxClients; requiresPassword = packet.RequiresPassword; port = packet.Port; name = packet.Name ?? ""; temporaryDocument = packet.temporaryDocument; endPoint = listenEndpoint; lastUpdateTimer = new Marzersoft.Timer(); lastPingTimer = new Marzersoft.Timer(); UpdatePing(); }