Genesys.Bayeux.Client
0.0.4
dotnet add package Genesys.Bayeux.Client --version 0.0.4
NuGet\Install-Package Genesys.Bayeux.Client -Version 0.0.4
<PackageReference Include="Genesys.Bayeux.Client" Version="0.0.4" />
paket add Genesys.Bayeux.Client --version 0.0.4
#r "nuget: Genesys.Bayeux.Client, 0.0.4"
// Install Genesys.Bayeux.Client as a Cake Addin
#addin nuget:?package=Genesys.Bayeux.Client&version=0.0.4
// Install Genesys.Bayeux.Client as a Cake Tool
#tool nuget:?package=Genesys.Bayeux.Client&version=0.0.4
.NET Bayeux Client
Bayeux is a protocol that enables web-friendly message transport over HTTP, WebSockets, etc.
This library provides a client for receiving events from a Bayeux server, through the HTTP long-polling transport, or WebSockets. It provides convenient async methods.
Quick start
This is an example of usage:
var httpClient = new HttpClient();
var bayeuxClient = new BayeuxClient(
new HttpLongPollingTransportOptions()
{
HttpClient = httpClient,
Uri = "http://localhost:8080/bayeux/",
});
bayeuxClient.EventReceived += (e, args) =>
Debug.WriteLine($"Event received on channel {args.Channel} with data\n{args.Data}");
bayeuxClient.ConnectionStateChanged += (e, args) =>
Debug.WriteLine($"Bayeux connection state changed to {args.ConnectionState}");
bayeuxClient.AddSubscriptions("/**");
await bayeuxClient.Start();
Logging
Logger name is Genesys.Bayeux.Client
.
Logging levels used are:
Debug
: Contents of messages.Info
: Messages about connection availabity and other significant infrequent messages.Warn
: Recoverable errors. For example, connection errors with reconnection strategy.Error
: Unexpected errors.
This library uses LibLog for logging. It will automatically adapt to NLog, Log4Net, Serilog and Loupe.
You may also provide your own custom logger implementation by calling:
Genesys.Bayeux.Client.Logging.LogProvider.SetCurrentLogProvider(<My ILogProvider implementation>);
If none of these are available, System.Diagnostics.TraceSource will be used. (See how to configure tracing).
Features
Start modes
Different applications need different ways to start a Bayeux connection.
Some applications may want to wait and check if the first connection succeeds. This is typical for interactive user applications. For this case, use method Start(CancellationToken)
.
Other applications, like the ones running in the background, may continue to run with an failed first connection, as long as reconnections are tried. For this case, use method StartInBackground()
.
Connection and subscription recovery
Reconnections and automatic channel re-subscriptions are implemented.
Reconnection delays can be provided as a parameter of the BayeuxClient
constructors.
Subscription modes
Usually, applications can't recover from a failed subscribed channel, and they can't control when the connection is available anyway. These applications use the AddSubscription
and RemoveSubscription
methods.
Picky applications that want to make sure that subscriptions are successful use the Subscribe
and Unsubscribe
methods.
WebSockets
WebSocket transport is supported:
var bayeuxClient = new BayeuxClient(
new WebSocketTransportOptions()
{
Uri = new Uri("ws://localhost:8080/bayeux/"),
});
Customizing HTTP POSTs
The IHttpPost
interface is offered for clients that want to provide their own HTTP POST implementation. This is also useful to implement retries for servers that may occasionally fail, in need of a session refresh.
TaskScheduler
for event publishing
It is important to publish events in the proper threading context, for not running into obscure multithreading issues.
By default, a proper scheduler will be chosen, based on the current SynchronizationContext
. This will do the right thing for Windows Forms or WPF applications. If there is no current SynchronizationContext
, a TaskScheduler
with ordered execution of events will be created and used.
The client can also provide a TaskScheduler
as a parameter to BayeuxClient
constructors.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net452 is compatible. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.5.2
- Microsoft.CSharp (>= 4.4.0)
- Newtonsoft.Json (>= 11.0.2)
- System.Net.WebSockets.Client.Managed (>= 1.0.22)
-
.NETStandard 2.0
- Microsoft.CSharp (>= 4.4.0)
- Newtonsoft.Json (>= 11.0.2)
- System.Net.WebSockets.Client.Managed (>= 1.0.22)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|