Пример #1
0
 /// <param name="eventTaskScheduler">
 /// <para>
 /// TaskScheduler for invoking events. Usually, you will be good by providing null. If you decide to
 /// your own TaskScheduler, please make sure that it guarantees ordered execution of events.
 /// </para>
 /// <para>
 /// If null is provided, SynchronizationContext.Current will be used. This means that WPF and
 /// Windows Forms applications will run events appropriately. If SynchronizationContext.Current
 /// is null, then a new TaskScheduler with ordered execution will be created.
 /// </para>
 /// </param>
 /// <param name="reconnectDelays">
 /// When a request results in network errors, reconnection trials will be delayed based on the
 /// values passed here. The last element of the collection will be re-used indefinitely.
 /// </param>
 public BayeuxClient(
     HttpLongPollingTransportOptions options,
     IEnumerable <TimeSpan> reconnectDelays = null,
     TaskScheduler eventTaskScheduler       = null)
 {
     this.transport          = options.Build(PublishEventsAsync);
     this.eventTaskScheduler = ChooseEventTaskScheduler(eventTaskScheduler);
     this.connectLoop        = new ConnectLoop("long-polling", reconnectDelays, this);
 }
Пример #2
0
        static async Task Main(string[] args)
        {
            var loggerFactory = new LoggerFactory();
            var streamingUri  = new Uri("<uri>");
            var observer      = Observer.Create <JObject>(OnNext, OnError);
            var clientOptions = new HttpLongPollingTransportOptions(() => new HttpClient(),
                                                                    streamingUri, observer);
            var connection = new BayeuxConnection(clientOptions, new ReconnectDelays(), loggerFactory);
            var cancellationTokenSource = new CancellationTokenSource();
            await connection.StartAsync(cancellationTokenSource.Token);

            var channels = new (string, FSharpValueOption <long>)[]