Book Image

SignalR Real-time Application Cookbook

By : Roberto Vespa
Book Image

SignalR Real-time Application Cookbook

By: Roberto Vespa

Overview of this book

Table of Contents (18 chapters)
SignalR Real-time Application Cookbook
About the Author
About the Reviewers

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:

  1. Add a Hub called EchoHub.

  2. Add an OWIN Startup class named Startup with its Configuration() method containing just a simple app.MapSignalR(); bootstrap call.

  3. 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
        public class EchoHub...