private NetworkArguments ValidateValues(CancellationToken token) { #if !DEVEL if (_settings.GetIP().Equals(Defaults.IP) == true) { throw new MomNotRegisteredException(String.Format("IP is no valid ({0}", Defaults.IP)); } #endif NetworkArguments netArg = new NetworkArguments(); token.ThrowIfCancellationRequested(); netArg.Ip = _settings.GetIP(); netArg.Port = _settings.GetPort(); int connectTimeout = _settings.GetConnectTimeOut(); int netTimeout = _settings.GetNetworkTimeoutSeconds(); if (connectTimeout > netTimeout) { netArg.ReceiveTimeoutSeconds = netTimeout; netArg.SendTimeoutSeconds = netTimeout; } else { netArg.ReceiveTimeoutSeconds = connectTimeout; netArg.SendTimeoutSeconds = connectTimeout; } netArg.NoDelay = true; netArg.LingerArguments = new MomLinger { Enable = false, Timeout = 0 }; netArg.ConnectTimeoutSeconds = _settings.GetConnectTimeOut(); return(netArg); }
public async Task <IConnectedNetworkClient> GetNewConnection(NetworkArguments netArgs, CancellationToken token = default(CancellationToken)) { return(await _networkFactory.Connect(netArgs, token)); }
protected async Task <IConnectedNetworkClient> Connect(CancellationToken token) { NetworkArguments netArgs = ValidateValues(token); return(await _network.GetNewConnection(netArgs, token)); }