Broadcasting to all connected clients
After several examples where a single client was involved at a time, we'll start looking at scenarios where multiple clients are connected at the same time, and we'll start making them interact. We will see how a Hub can call back into all the connected clients from the context of a single remote method call performed by just one of them. This is where SignalR becomes a more interesting and outstanding library!
Getting ready
Before proceeding, we need to create a new empty web application, which we'll call Recipe07
.
How to do it…
As usual, we need some simple steps to get started as follows:
Add a Hub called
EchoHub
.Add an OWIN Startup class named
Startup
with itsConfiguration()
method containing just a simpleapp.MapSignalR();
bootstrap call.Modify the file content to make it look like the following code:
using System; using Microsoft.AspNet.SignalR; using Microsoft.AspNet.SignalR.Hubs; namespace Recipe07 { [HubName("echo")] public class EchoHub...