示例#1
0
        public AblyHttpOptions(ClientOptions options)
        {
            IsSecure                 = options.Tls;
            Port                     = options.Tls ? options.TlsPort : options.Port;
            Host                     = options.FullRestHost();
            IsDefaultHost            = options.IsDefaultRestHost;
            DisconnectedRetryTimeout = options.DisconnectedRetryTimeout;
            SuspendedRetryTimeout    = options.SuspendedRetryTimeout;
            HttpOpenTimeout          = options.HttpOpenTimeout;
            HttpRequestTimeout       = options.HttpRequestTimeout;
            HttpMaxRetryCount        = options.IsDefaultRestHost ? options.HttpMaxRetryCount : 1;
            HttpMaxRetryDuration     = options.HttpMaxRetryDuration;
            FallbackRetryTimeOut     = options.FallbackRetryTimeout;
            FallbackHosts            = options.GetFallbackHosts();
            FallbackHostsUseDefault  = options.FallbackHostsUseDefault;
            AddRequestIds            = options.AddRequestIds;

            NowFunc = options.NowFunc;
            Logger  = options.Logger;
        }
示例#2
0
        internal AblyRealtime(ClientOptions options, Func <ClientOptions, IMobileDevice, AblyRest> createRestFunc, IMobileDevice mobileDevice = null)
        {
            if (options.Logger != null)
            {
                Logger = options.Logger;
            }

            Logger.LogLevel = options.LogLevel;

            if (options.LogHandler != null)
            {
                Logger.LoggerSink = options.LogHandler;
            }

            CaptureSynchronizationContext(options);
            RestClient = createRestFunc != null?createRestFunc.Invoke(options, mobileDevice) : new AblyRest(options, mobileDevice);

            Push = new PushRealtime(RestClient, Logger);

            Connection = new Connection(this, options.NowFunc, options.Logger);
            Connection.Initialise();

            if (options.AutomaticNetworkStateMonitoring)
            {
                IoC.RegisterOsNetworkStateChanged();
            }

            Channels = new RealtimeChannels(this, Connection, mobileDevice);
            RestClient.AblyAuth.OnAuthUpdated = ConnectionManager.OnAuthUpdated;

            State = new RealtimeState(options.GetFallbackHosts()?.Shuffle().ToList(), options.NowFunc);

            Workflow = new RealtimeWorkflow(this, Logger);
            Workflow.Start();

            if (options.AutoConnect)
            {
                Connect();
            }
        }