In this article, I shall show you a quick demonstration SignalR in Xamarin Android app.
Last time, I had made a simple signalR chat client app. Today, I shall show you a quick demonstration of SignalR.
Signalr is a library for asp.net developers that revamps the path toward adding progressing web value to applications. Consistent web convenience is the ability to have server code push substance to related clients immediately as it twists up recognizably available, rather than having the server sit tight for a client to request new data.
Step 1
(ProjectName: SignalR_Service)
Step 2
Next go to Solution Explorer-> Project Name-> then Right Click to Add -> HTML Page.
(HtmlPage Name: Index)
Again go to Solution Explorer-> Project Name-> then Right Click to Add -> New Item-> SignalR Hub Class (v2) with name ChatHub.cs. The hub class essentially is a type of connection that makes connectivity between server and client.
(Class Name: NewHub.cs)
Step 4
We need to add a Startup class so, go to Solution Explorer-> Project Name-> then Right Click to Add -> New Item-> OWIN Startup Class with name Startup.cs
(Class Name: Startup)
Step 5
Next go to Solution Explorer-> Project Name-> ChatHub then create a chathub class and replace following code with Hello method.
(File Name: ChatHub.cs)
Step 7
This service successfully publish on microsoft azure. Now everyone can use and access this service from given url. http://azuresignalrserver.azurewebsites.net/
Client Side
Open Visual Studio-> New Project-> Templates-> Visual C#-> Android-> Blank app and give the project name SignalR_Drag.
(ProjectName: SignalR_Drag)
Next, open Solution Explorer-> Project Name-> Resources-> Layout-> Main.axml. Open main.axml file and add following code.
(FileName: Main.axml)
Layout
Step 3
Go to Solution Explorer-> Components -> then Right Click-> Get More Components. In this way, you can move on xamarin components store then search SignalR and add to app.
Finally, we have done our SignalR application, just rebuild and run the project. You will have the result like below.
Xamarin.Forms For Beginners