Chapter 2: Hub

Chapter 2: Hub

SignalR uses hubs to communicate between clients and servers. A hub is a high-level pipeline that allows a client and server to call methods on each other. SignalR handles the dispatching across machine boundaries automatically, allowing clients to call methods on the server and vice versa. You can pass strongly-typed parameters to methods, which enables model binding. SignalR provides two built-in hub protocols: a text protocol based on JSON and a binary protocol based on MessagePack. MessagePack generally creates smaller messages compared to JSON. Older browsers must support XHR level 2 to provide MessagePack protocol support. Hubs call client-side code by sending messages that contain the name and parameters of the client-side method. Objects sent as method parameters are deserialized using the configured protocol. The client tries to match the name to a method in the client-side code. When the client finds a match, it calls the method and passes to it the deserialized parameter data.

Adding a Hub to an ASP.NET project

Step1 : Open Visual Studio 


Step2 : search [ asp.net ] template

select [ Asp.NET Web Application (.Net Framwork) ]

click [ Next ] button



Step3 : set project name[ AddHubClass ] 

click [ Create ] button



Step4 : select [ Empty ]

click [ Create ] button



Step5 : Right Click On [ AddHubClass ]

 [ Add  ] Click [New Item]



Step6 : search SignalR click [ SignalR Hub Class (v2) ]

set class Name [ MyHub1.cs ] 

Note: If SignalR Hub Class Not Found Than Install Following Library

Install Library Click Here.  


Install Library

Step5 : Right Click On [ AddHubClass ]

Click [Manage NuGet Packages ]






Note : When You add SignalR Hub Class Script folder automatically Add 
















Comments