Calling back the caller from a Hub's method
With this recipe, we are actually starting to look at more interesting and real-time SignalR features. We will see how a Hub can call back into a client that just performed a remote method call.
Getting ready
Before starting with this recipe, we need to create a new empty web application, which we'll call Recipe06
.
How to do it…
Let's start building the server-side portion of this recipe using the following steps:
We must first add a Hub called
EchoHub
.We must then add an OWIN Startup class named
Startup
, containing just a simpleapp.MapSignalR();
bootstrap call inside theConfiguration()
method.Let's make the Hub's content look like the following:
using System; using Microsoft.AspNet.SignalR; using Microsoft.AspNet.SignalR.Hubs; namespace Recipe06 { [HubName("echo")] public class EchoHub : Hub { public void Hello() { var msg = string.Format("Greetings {0}, it's {1:F}!", Context...