可以在没有 Web 浏览器客户端的情况下使用 SignalR 吗? [英] Can SignalR be used without a web browser client?

查看:34
本文介绍了可以在没有 Web 浏览器客户端的情况下使用 SignalR 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开展一个项目,该项目将异步进程置于同步前端以使 Web 调用看起来是同步的,并且正在探索使用 SignalR 将它们联系在一起.

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.

我们使用异步的 WCF 端点托管服务,并且适用于我们的大多数客户端.他们向我们发送数据,我们对其进行处理,而他们在处理完数据后没有得到响应.我们的环境是多层的,设计上是异步的.

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.

我们需要允许客户端打开到我们的 WCF 服务的连接,传输数据,并等待响应.这个想法是让 WCF 服务为客户端及其数据创建一个唯一标识符,并将这些数据交给异步环境进行处理.同时,WCF 服务将打开与中央 HUB 的连接并等待指示特定数据已完成处理的响应.然后 HUB 会以状态响应 WCF 服务,WCF 服务会响应原始客户端.

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.

我为此目的探索 SignalR 主要有两个原因:

I'm exploring SignalR for this purpose for two main reasons:

  • 我喜欢 SignalR 使用的连接技术协议.它重量轻,可以根据各种条件使用多种不同的技术.
  • 它可以很好地管理和区分客户端连接,允许将数据轻松发送到单个客户端.这消除了我们在异步过程完成时必须尝试区分与 WCF 服务的各个客户端连接的需要.

根据我所了解的有关 SignalR 的所有内容,它使用 javascript 和 RPC 与客户端进行通信,并且我所见过的所有实现都将 Web 浏览器作为客户端.在这个实现中,客户端是一个 .NET 程序集;具体来说,WCF 服务.这是可行的,还是我应该追求不同的技术?

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

推荐答案

SignalR 基本上是通过各种网络技术(HTTP 轮询、网络套接字等)的双向异步通信的映射

SignalR is basically a mapping of two-way asynchronous communication over various web technologies (HTTP polling, web sockets, etc)

有适用于 C#、Java、iOS 和其他可能的 SignalR 客户端库.您不仅限于浏览器客户端.(我相信 SignalR nuget 包包含一个 C# 客户端库,尽管我已经有一段时间没有使用它了.)

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.)

这篇关于可以在没有 Web 浏览器客户端的情况下使用 SignalR 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆