コード例 #1
0
ファイル: RealtimeChannels.cs プロジェクト: ably/ably-dotnet
 internal RealtimeChannels(AblyRealtime realtimeClient, Connection connection, IMobileDevice mobileDevice = null)
 {
     _realtimeClient = realtimeClient;
     Logger          = realtimeClient.Logger;
     connection.InternalStateChanged += ConnectionStateChange;
     _mobileDevice = mobileDevice;
 }
コード例 #2
0
        internal RestChannel(AblyRest ablyRest, string name, ChannelOptions options, IMobileDevice mobileDevice = null)
        {
            Name      = name;
            _ablyRest = ablyRest;
            _options  = options;
            _basePath = $"/channels/{name.EncodeUriPart()}";

            if (mobileDevice != null)
            {
                _pushChannel = new PushChannel(name, ablyRest);
            }
        }
コード例 #3
0
 internal AblyRest(ClientOptions clientOptions, IMobileDevice mobileDevice)
 {
     Options = clientOptions;
     InitializeAbly(mobileDevice);
 }
コード例 #4
0
ファイル: AblyRealtime.cs プロジェクト: ably/ably-dotnet
 internal AblyRealtime(ClientOptions options, IMobileDevice mobileDevice)
     : this(options, CreateRestFunc, mobileDevice)
 {
 }
コード例 #5
0
ファイル: AblyRealtime.cs プロジェクト: ably/ably-dotnet
        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();
            }
        }
コード例 #6
0
 internal RestChannels(AblyRest restClient, IMobileDevice mobileDevice = null)
 {
     _ablyRest     = restClient;
     _mobileDevice = mobileDevice;
 }
コード例 #7
0
ファイル: MockHttpRestSpecs.cs プロジェクト: ably/ably-dotnet
        internal AblyRest GetRestClient(Func <AblyRequest, Task <AblyResponse> > handleRequestFunc = null, Action <ClientOptions> setOptionsAction = null, IMobileDevice mobileDevice = null)
        {
            var options = new ClientOptions(ValidKey)
            {
                UseBinaryProtocol = false
            };

            setOptionsAction?.Invoke(options);

            return(GetRestClient(handleRequestFunc, options, mobileDevice));
        }
コード例 #8
0
ファイル: MockHttpRestSpecs.cs プロジェクト: ably/ably-dotnet
        internal AblyRest GetRestClient(Func <AblyRequest, Task <AblyResponse> > handleRequestFunc, ClientOptions options, IMobileDevice mobileDevice = null)
        {
            var client = new AblyRest(options, mobileDevice);

            client.ExecuteHttpRequest = request =>
            {
                Requests.Add(request);
                if (handleRequestFunc != null)
                {
                    return(handleRequestFunc(request));
                }

                return(DefaultResponse.ToTask());
            };
            return(client);
        }
コード例 #9
0
        private static AblyRealtime GetRealtimeClientWithFakeMessageHandler(ClientOptions options = null, FakeHttpMessageHandler fakeMessageHandler = null, IMobileDevice mobileDevice = null)
        {
            var clientOptions = options ?? new ClientOptions(ValidKey);

            clientOptions.SkipInternetCheck = true; // This is for the Unit tests
            var client = new AblyRealtime(clientOptions, mobileDevice);

            if (fakeMessageHandler != null)
            {
                client.RestClient.HttpClient.CreateInternalHttpClient(TimeSpan.FromSeconds(10), fakeMessageHandler);
            }

            return(client);
        }
コード例 #10
0
        internal AblyRealtime GetRealtimeClient(ClientOptions options = null, Func <AblyRequest, Task <AblyResponse> > handleRequestFunc = null, IMobileDevice mobileDevice = null)
        {
            var clientOptions = options ?? new ClientOptions(ValidKey);

            clientOptions.SkipInternetCheck = true; // This is for the Unit tests
            var client = new AblyRealtime(clientOptions, (opts, device) => GetRestClient(handleRequestFunc, clientOptions, device), mobileDevice);

            return(client);
        }