/// <summary> /// Sends a request into the network /// </summary> /// <returns>The awaitable task.</returns> /// <param name="req">The request to transmit.</param> public static void TransmitRequest(PendingNetworkRequest req) { if (_connector == null) { lock (_lock) if (_connector == null) { _connector = new NetworkClientConnector(NameServerHostname, NameServerPort); _connectorTask = _connector.RunAsync(); } } _connector.Requests.Write(req); }
/// <summary> /// Configure this instance for network access. /// </summary> /// <param name="nameserverhostname">The hostname for the nameserver.</param> /// <param name="nameserverport">The port for the nameserver.</param> /// <param name="singlechannelserver">Set to <c>true</c> to bypass the nameserver and connect directly to the channelserver.</param> public static void Configure(string nameserverhostname, int nameserverport, bool singlechannelserver) { lock (_lock) { if (_connectorTask != null && !_connectorTask.IsCompleted) { throw new Exception("Cannot change configuration while running"); } NameServerHostname = nameserverhostname; NameServerPort = nameserverport; SingleChannelServer = singlechannelserver; if (_connectorTask != null) { _connector = null; _connectorTask = null; } } }