WampSharp v18.6.1 release notes
New features
ObserveOn extension method
From this version, the client fluent syntax api supports a new ObserverOn
method. This method allows you to specify an IScheduler that WAMP messages will be observed on. This for instance allows to ensure that reflection based callee methods or reflection based subscriber event handlers are invoked on the Dispatcher thread.
Usage example:
IWampChannel channel =
channelFactory.ConnectToRealm("realm1")
.WebSocketTransport("ws://127.0.0.1:8080/ws")
.JsonSerialization()
.ObserveOn(DispatcherScheduler.Current)
.Build();
RawSocket Ssl support
From this version, RawSocket Ssl security is supported.
The RawSocket fluent api now includes a new extension method called SslConfiguration
, which allows you to specify the arguments sent in the AuthenticateAsClientAsync method.
Similarly, the RawSocketTransport constructor now receives as a parameter a ServerSslConfiguration
object, which allows you to specify the arguments sent in the AuthenticateAsServerAsync method.
ASP.NET Core RawSocket implementation
This version includes an implementation of the RawSocket protocol using the new Microsoft.AspNetCore.Connections.Abstractions package, part of Project Bedrock. This implementation is present in the package WampSharp.AspNetCore.RawSocket.
Usage sample:
using System.Net;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using WampSharp.AspNetCore.RawSocket;
using WampSharp.Binding;
using WampSharp.V2;
public class Program
{
public static void Main(string[] args)
{
WampHost wampHost = new WampHost();
JTokenJsonBinding jsonBinding = new JTokenJsonBinding();
IWebHost host =
WebHost.CreateDefaultBuilder(args)
.UseKestrel(options =>
{
options.Listen(IPAddress.Loopback, 8080,
builder =>
{
// Configure RawSocket transport
wampHost
.RegisterTransport(new AspNetCoreRawSocketTransport(builder),
jsonBinding);
});
})
.Configure(app =>
{
wampHost.Open();
})
.Build();
host.Run();
}
}
This allows you to listen to both RawSocket and WebSocket requests on the same port. For example, the following code listens both to WAMP RawSocket requests on port 8080 and to WAMP WebSocket requests on ws://localhost:8080/ws/
(using the WampSharp.AspNetCore.WebSockets.Server package):
using System.Net;
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using WampSharp.AspNetCore.RawSocket;
using WampSharp.AspNetCore.WebSockets.Server;
using WampSharp.Binding;
using WampSharp.V2;
public class Program
{
public static void Main(string[] args)
{
WampHost wampHost = new WampHost();
JTokenJsonBinding jsonBinding = new JTokenJsonBinding();
IWebHost host =
WebHost.CreateDefaultBuilder(args)
.UseKestrel(options =>
{
options.Listen(IPAddress.Loopback, 8080,
builder =>
{
// Log all of the http bytes as they are sent and received
builder.UseConnectionLogging();
// Configure RawSocket transport
wampHost
.RegisterTransport(new AspNetCoreRawSocketTransport(builder),
jsonBinding);
});
})
.Configure(app =>
{
app.Map("/ws",
builder =>
{
builder.UseWebSockets();
// Configure WebSockets transport
wampHost.RegisterTransport
(new AspNetCoreWebSocketTransport(builder),
jsonBinding);
});
wampHost.Open();
})
.Build();
host.Run();
}
}
Internal changes
- WampSharp.RawSocket now uses internally Microsoft.IO.RecyclableMemoryStream instead of System.Buffers, in order to manage MemoryStream lifetimes, as the previous implementation used System.Buffers incorrectly.
- Optimizations for router-side pub/sub publications were made for RawSocket implementation. These also affect (minorly) the WampSharp.WebSockets based WebSockets implementations (i.e. ASP.NET, ASP.NET Core, Owin, HttpListener).
- A lot of auto refactoring was done to leverage C# 6.0 and C# 7.0 features. These include expression bodied properties,
nameof
operator, readonly properties, string interpolation, pattern matching, var out, etc. This should not affect the implementation in any way. - Most of the dependencies were updated to latest version. As a result
- WampSharp.Fleck and WampSharp.Default.Router are now available for .NET Standard 2.0.
- The System.Reactive package reference was updated to v4.0.0, which now consists of a single dll, instead of 5 dlls.
- If you need support for a framework variant which is not supported by .NET Standard 2.0, please specify it and explain why in this thread.