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

Starting a Hub connection

In this recipe, we'll describe the first operation that is necessary in every client-side portion of a SignalR application: connecting to a server. We'll quickly see how to do it and how the asynchronous nature of SignalR is already clear since the very first step performed by any client.

Getting ready

This recipe is only about performing a connection; that's why we do not need a server-side concrete Hub yet. Therefore, there is only one simple step that we need to perform before moving to the client-side code as follows:

  1. We need to add an OWIN Startup class and set it up so that the Configuration() method calls app.MapSignalR(); in order to properly initiate the server-side endpoint, as we already did several times in the previous chapters. This method is contained in the Microsoft ASP.NET SignalR System.Web package, which we can find on NuGet. If we use the graphical UI, we should search for it and install it from there. This is depicted in the following screenshot...