Deeper SignalR Integration
I'd like to see a deeper integration between ServiceStack and SignalR. Here are a few ideas that I've so far ran into...
1. A Hub Authorization Attribute which implements IAuthorizeHubConnection and/or IAuthorizeHubMethodInvocation.
2. Some sort of JsonServiceClient integration with HubConnections. Maybe automatically associating Cookies with a new HubConnection. Plus exception handling wrappers (i.e. Like an Unauthorized exception is thrown within a SignalR exception).
3. Centralized documentation outlining what needs to be changed in the web.config for SignalR to co-exist with ServiceStack. Also why the UseBufferedStream property should be enabled for SignalR.
4. This might require a separate feature request but an updated example app showing SignalR 2.0 integrated with ServiceStack 4.x. Only Examples I've seen have been with SignalR 1.x
The way ServiceStack and SignalR will be able to integrate in future will be through .NET Core’s IApplicationBuilder pipeline which by design supports running multiple frameworks within the same App that can now share the same default route namespace.
From the v4.5.2, ServiceStack now supports running on .NET Core, please see the guide in the full release notes which shows how to register ServiceStack’s AppHost in .NET Core: http://docs.servicestack.net/releases/v4.5.2.html
SignalR for .NET Core has yet to be released but it’s expected you’ll be able to access SignalR via its dependencies registered in .NET Core’s Startup which will also be injected in your Services like normal IOC dependencies.
We’ll update this feature request again with an example showing a demo of ServiceStack + SignalR together in the same App once SignalR is available on .NET Core in 2017.
The integrated ServiceStack solution for real-time events is to use Server Events.
But if preferred you can happily configure SignalR in the same .NET Core App as ServiceStack, neither framework has dependencies or knowledge of each other but they both have access to the same dependencies registered in .NET Core's IServiceCollection.
Sam Bosell commented
Out of curiosity is there any movement on this?
Johan Mulder commented
This is awesome news ! Luv the idea that Rest api , signalr and server sent events can be fully integrated in SS. What will be absolutely awesome is Rest , SignalR , SSE and Akka.net
That will put SS on a different planet ;)
Note that authenticated SSE isn't supported in IE9 and earlier browsers. In other browsers that don't support XmlHttpRequest to send http cookies and/or custom headers it cannot be implemented either.
Sadly to say, for this reason we are forced to leave SSE toward SignalR.
Jonas Bohlin commented
We're using SignalR and we're seriously considering moving to ServiceStack for our api v2. But we'd like to keep using signalr for some operations, and here's why:
Server Sent Events are virtually unusable if you're serving content to iOS-devices. iOS only allows a small number of concurrent connections to any server, and an SSE endpoint blocks one of those connections, resulting in other requests not being allowed through. WebSockets doesn't cause this, on the other hand.
Johann Klemmack commented
I've completed an initial typed C# client implementation at https://github.com/jklemmack/ServerSentEvents4ServiceStack. This repo also has a lighter-weight server implementation, where the "data" elements are raw DTOs, and the "event" field is used to govern the categorization of messages.
Apologies, I meant just SS's JS client bindings. The C# libraries have yet to be developed, I'll look at providing some integration with C# soon.
Ryan Britton commented
Johann Klemmack commented
Any plans on a JsonServiceClient-based C# EventSource client?