The Send() method broadcasts the message to the users by passing the name and the message as the parameters.The Send To Specific() method on the other hand broadcasts the message to a specific user.Now let’s proceed and create the Signal RChat view.Step 4: Adding a View The first thing we need here is to add a Chat Room folder within the View folder. Keep in mind that public methods defined within the Hub class are intended to be called from the client code (Java Script).Note: Adding a reference to the j Query script within your View will cause an error when running your application that uses Signal R.This is because the reference to the j Query script will be duplicated and the order of the script references will be changed and that can cause the Signal R script to throw an exception.Before we create a Hub, let’s add a new folder first within the root of the project. Right-click on that folder and select Add As you may have noticed, the Chat Hub class inherits from Microsoft. These client-side methods will act as a proxy to the server-side methods.You write an implementation of public methods from the Hub in your client-side code so that the Hub can call it and thereby provide the response.
The On Disconnected() method handles the removing of users if someone leaves the chat room.
Then it will call the Notify() method to add the new user to the dictionary and notify other users that someone has joined the chat room.
The next function updates the message logs, available users and the online user’s panel when someone joins the room.
The show Modal User Nick Name() function calls the j Query UI dialog.
This function will be called when the browser is loaded to prompt the user to enter their name before joining the chat room.;) Step 3: Adding a Controller To add a new controller, just right-click on the Controller’s folder and then select Add As you can see, there’s nothing really fancy in the Controller.