问题
I'm working on a project to front an asynchronous process with a synchronous front-end to make the web call appear as synchronous, and am exploring the use of SignalR to tie it all together.
We host a service with a WCF endpoint which is asynchronous, and that works for most of our clients. They send us data, and we process it, without them getting a response after that data is processed. Our environment is multi-tier, and asynchronous by design.
There is a need, however, to host a synchronous front-end, where callers to our service can receive a response after the operation on the data through our environment has completed.
We need to allow the client to open up a connection to our WCF service, transmit data, and wait for a response. The idea is to have the WCF service create a unique identifier for the client and their data, and hand this data off to the asynchronous environment for processing. At the same time, the WCF service will open up a connection to a central HUB and wait for a response indicating that the particular data has completed processing. The HUB will then respond to the WCF service with a status, and the WCF service will respond to the original client.
I'm exploring SignalR for this purpose for two main reasons:
- I like the connection technology protocol that SignalR uses. It's light-weight and can use several different technologies depending on various conditions.
- It manages and distinguishes client connections well, allowing data to easily be sent to a single client. This eliminates the need of us having to try to distinguish individual client connections to the WCF service when the asynchronous process completes.
With everything I've read about SignalR, it uses javascript and RPC to communicate back to the client, and all of the implementations I've seen have a web browser as the client. In this implementation, the client is a .NET assembly; specifically, a WCF service. Is this feasible, or should I pursue a different technology?
I've included a high-level sequence diagram to help illustrate the process. Synchronous Fronted Call
回答1:
SignalR is basically a mapping of two-way asynchronous communication over various web technologies (HTTP polling, web sockets, etc)
There are SignalR client libraries available for C#, Java, iOS and probably others. You are not limited to browser clients. (I believe the SignalR nuget package contains a C# client library, although it's been a while since I used it.)
来源:https://stackoverflow.com/questions/33003601/can-signalr-be-used-without-a-web-browser-client