.NET Console application using SignalR - signalr

I am currently evaluating a requirement for a project for which I am considering SignalR.
Here is a brief:
We want to have a server at our end that can send instructions to a client piece sitting somewhere in the world. The client piece then is supposed to do some local processing and send back a response that the server will show to the user.
The client piece by itself should also be executable and generate the report.
So we need some .net Code(console) at the client end(across the world) and some code at the hub end(our end).
Although this is not a ASP.net application I feel like this is a good fit for websocket communication.
I am looking for some guidance on getting a very very basic structure chalked out as I am new to SignalR.
Technologies :
.net 4.5

Follow the guides for setting up your hub and using the .Net Client.
Essentially, the console applications are clients to your hub. Think of the hub as a relay. You can google "signalr console application" and get plenty of information on how to set that up.

Related

How can I communicate between a server and client in a ASP.NET webapp?

I want to make a pictionary like webapp.
I chose to develop using the .net platform, and decided to make a blazor client with a asp.net server, but I don't know how to communicate between them.
When a player is drawing something, as he/she draws, whatever he/she is drawing should appear on the other player's client, but I don't know how should to send this data to the server and back to the other clients.
I took a look at gRPC but don't know if this is the right tool for this kind of communication assuming a tickrate of 20 to 50 times a second.
You may create a Blazor WebAssembly App, which is running on the browser, and whose default means of transport is HTTP. However, you can use SignalR Client for your requirements. This is the way to go. Look up in the docs for the sample of creating a chat app in Blazor WebAssembly employing SignalR Client. There are also code samples created by the community demonstrating how to create advanced chat applications and games, and every thing involving that.
Good luck...

SignalR .NET Client with Backplane: clarification

I'm working on getting Microsoft Orleans "Grains" to put events onto a SignalR bus. There's an example project that does this, and I've linked to SignalR integration below.
It looks to me that this sample is using meta-data from the Azure Web and Worker roles to enumerate all the web roles, and explicitly publish messages to each one. It seems to me that if SignalR's backplane is configured properly on the azure web roles that this shouldn't be necessary -- one HubConnection/HubProxy should do it. Is that right?
In fact, when I look closely at the file linked to below, and see some of the odd logic in the Hub itself, I wonder if the sample functions as a rudimentary backplane.
I'm hoping someone with deeper SignalR experience can clarify this for me.
SignalR integration example: https://orleans.codeplex.com/SourceControl/latest#src/samples/GPSTracker/GPSTracker.GrainImplementation/PushNotifierGrain.cs
The sample is a rudimentary backplane, in that it sends the message to all web roles instances present in the deployment, and therefore doesn't require a complete backplane (such as Redis). However, it won't propgate client originated messages to the other servers.
A more complete Orleans backplane for SignalR is available here: https://github.com/OrleansContrib/OrleansR

SignalR notifying both asp.net and web api clients host on separate site

I'm going to build my own system include asp.net web site and web api, they are host on separate site. Architect diagram like image link below.
Every time client update something. I need to notify to the others. For example if client 1 upload a photo via web, then client 3 and (mobile app) and client 4(desktop app) should get a notification.
My problem is how to tell SignalR send notify to clients in this case. Please advice.
Your diagram must be changed in order to achieve what you need.
In order for this to work all the client types must be SignalR aware. For the web application it's straightforward since the "client" code is the website code itself.
For the mobile and desktop you have an extra layer (webapi) which in this case is an obstacle.
You should define a SignalR hub and connect to it from all the clients: WebApp, MobileApp, DesktopApp.
Knowing this, you can make a WebAPI project containing all the API methods and the SignalR hub(s) and connect to it from the other applications, website included.
As far as I know this is the only way to make this work, as you need to include SignalR library in all the clients code and use it to communicate with the hub(s).

Is it possible to implement Database backed Push Notifications in ASP.NET WebAPI

I'm working on a client and server application, in which client requests 'client-specific' data from the server. I'm planning on switching to ASP.NET WebAPI for server so that client can take advantage of available .NET APIs to query server for data.
This scenario works perfectly fine when the client initially connects and requests data from server, However, instead of client constantly polling for data, it should just establish a persistent connection and the server should be able to monitor the database for changes and push new data to the client that has stale data. I came across SignalR and found that it can be used with WebAPI, but can't figure out how to integrate it with database monitoring i.e. a thread or process that is constantly monitoring database for updates. Any solution? I'm open to other non-WebAPI based .NET technologies as well - basically anything .NET based that will cut-down on the development time.
ASP.NET Web API supports PushStreamContent. Take a look at the section "Push Content" in http://blogs.msdn.com/b/henrikn/archive/2012/04/23/using-cookies-with-asp-net-web-api.aspx. Here, a timer triggers content written into the stream but you can use that to poll database and write into response or build some other better mechanism
signalR could fit your requirement. You can broadcast a message to all your user or just to part of them. Your client could be a browser (with javascript) or a .net client (WPF or else).
From the server, you can call a method on the client just like that
Clients.All.MyMethodOnTheClient(param1, param2)
or
Clients.Client(connectionId).MyMethodOnTheClient(param1, param2)
The topic is too broad to answer it in 5 min. I can advise you to start here.
Then browse the server api guide, the javascript guide and the .net client guide.
Don't worry. It's quite fast to have a complete tour.

Progress reporting from windows service hosted WCF to ASP.NET client (ajax maybe?)

We have a asp.net webform application (3.5) & a wcf service hosted via windows service (a service library which is activated when service is started). Both are deployed in same server.
WCF service is used for few long running task.
Now a client want some customized report which is gonna take significant time.
My idea is to show a progress of the task in the UI, but I am struggling with the correct way to do it.
Is it possible in the following way,
On request from page , service starts the processing asynchronously and report the status to some variable. (I don't want to write to database)
A asynchronous polling from client page, which intern communicate with another operation of wcf service to retrieve the the variable value.
Ajax client can communicate with the wcf service but it looks like the service need to be hosted as web application (don't understand much here)
Any Other thoughts? any option on using wcf callback (duplex communication)? too much confused.
We achieved something similar a year back.
1) We created a WCF Server with Singleton InstanceMode which processes the request and at the same time keep status as well. Another method e.g. GetStatus returns status to client. It also provides error details, in case of any error. However we also persisted the processing details.
2) On web page we async hit getstatus once request is initialized and showed a progress bar on web page.
This worked great for us.
You could look into using something like SignalR to push responses from your web application to your client (among other benefits, this uses the comet technique and so reduces the amount of polling you have to do).
To get a response from your WCF service to your web app, you can either use an async request to the service, or use a messaging solution such as Windows Azure Service Bus.
We use Client > JQuery > MVC > WCF > Service Bus > MVC > SignalR > Client as a pipeline and it works very well for long-running processes.

Resources