This short tutorial explains how to easily and fast add live update using ASP.NET SignalR to any of the demos created with DHTMLX Scheduler .NET. We’ll demonstrate how it can be implemented for the hotel room booking demo in MVC5:

Let’s start

Server side

To begin we, we should install SignalR library. It can be easily implemented in NuGet Package Manager Console by the following command:

PM > Install-Package Microsoft.AspNet.SignalR

Done. All necessary components have been installed.

Now we create a hub. In SignalR world, hub is an object that is responsible for keeping connections to clients that use our app and allows us to send and receive messages for them. Let’s create a new folder SingalR. Right-click on it -> Add-> New Item -> SignalR Hub Class

If your Visual Studio doesn’t contain SignalR Hub Class template, you can create an empty Hub.cs class with the following content:

[HubName("schedulerHub")] points at the name that will be used for accessing our hub from theclient-side.

By defining 'Send' function inside the hub we expose it to the client-side code - later we'll be able to call this method from JavaScript.

Let's look into the method - Clients.All contains all references to all users currently connected to our app, and Clients.All.addMessage sends text message to all of thos those users. So what the 'Send' method does is broadcasts the given message to all users that currently uses the app.

Each time user changes something in scheduler we'll pack the action info in JSON format and broadcast it to everybody. Then the client receives such message - we'll process it and do the action encoded in message JSON to their calendars so everybody will be in sync.

By defining 'Send' function inside the hub we expose it to the client-side code - later we'll be able to call this method from JavaScript.

Let's look into the method - Clients.All contains all references to all users currently connected to our app, and Clients.All.addMessage sends text message to all of thos those users. So what the 'Send' method does is broadcasts the given message to all users that currently uses the app.

Each time user changes something in scheduler we'll pack the action info in JSON format and broadcast it to everybody. Then the client receives such message - we'll process it and do the action encoded in message JSON to their calendars so everybody will be in sync.

Now we should add new Startup class in the following way: right-click on the project (App_Start folder) Add -> New Item -> OWIN Startup class

If your Visual Studio version doesn’t contain OWIN Startup class template, you can create an empty Startup.cs class with the following content: