コード例 #1
0
        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);
        }
コード例 #2
0
 public async Task <IConnectedNetworkClient> GetNewConnection(NetworkArguments netArgs, CancellationToken token = default(CancellationToken))
 {
     return(await _networkFactory.Connect(netArgs, token));
 }
コード例 #3
0
        protected async Task <IConnectedNetworkClient> Connect(CancellationToken token)
        {
            NetworkArguments netArgs = ValidateValues(token);

            return(await _network.GetNewConnection(netArgs, token));
        }