客户端可以仅使用 websockets 直接连接到 SignalR 吗? [英] Can a client connect directly to SignalR using only websockets?

查看:49
本文介绍了客户端可以仅使用 websockets 直接连接到 SignalR 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在服务器上使用 SignalR 构建实时数据 API.我将构建一个 Web 客户端,以通常的方式"连接 API.

I want to build a real-time data API using SignalR on the server. I will be building a web client that will connect with the API the "usual way".

但是,我希望第 3 方也能够连接到此 API.这些客户端可能是 Web 客户端或其他平台,如 Windows、Mac、iOS 等.理想情况下,它们只能通过普通的 websockets 进行连接,并且完全不知道 SignalR 是否在服务器上使用.

However, I would like 3rd parties to also be able to connect to this API. These clients may be web clients or other platforms such as Windows, Mac, iOS, etc. Ideally, they'd just be able to connect via plain websockets and be totally agnostic of whether SignalR is in use on the server or not.

似乎有很多库可供不同平台上的客户端使用(SwiftObjective-CJava/Android, c++ 等),这将允许他们连接到我的 API.另一种方法(其中一些库使用)是嵌入隐藏的 Web 视图.无论哪种方式,对第 3 方施加压力都相当大.它需要更简单.

It seems that there are a lot of libraries out there for clients on different platforms (Swift, Objective-C, Java/Android, c++, etc) that would allow them to connect to my API. Another approach (that some of these libraries use) is to embed a hidden web view. Either way it's quite a bit to impose on the 3rd parties. It needs to be simpler.

是否有一种方法可以编写仅使用 标准 websocket 调用 并直接与我的 SignalR 服务器对话,而无需包含任何 SignalR 特定脚本作为依赖项?非 Web 客户端是否可以执行相同操作(即进行标准的 Websocket 调用,没有嵌入的 Web 视图)?

Is there a way to write a web application (for example) that only uses standard websocket calls and talks directly to my SignalR server without needing to include any SignalR specific scripts as dependencies? Can a non-web client do the same (i.e. make standard websocket calls, with no embedded web view)?

基本上,我希望第 3 方需要付出的努力不会超过我决定制作一个 vanilla websocket API 并完全避免使用 SignalR 的情况.

Basically, I would like the effort 3rd parties need to go through to be no greater than if I decide to make a vanilla websocket API and avoid signalR entirely.

推荐答案

没有.你目前不能这样做.但是,根据此视频,在下一版本的 SignalR(Asp.NET Core 套接字)中可以实现这一点.第一个测试版计划于 2017 年年中发布.

No. You can´t do that currently. But that will be possible in the next version of SignalR (Asp.NET Core Sockets) according to this video. The first beta release is planned for mid 2017.

更新

看来确实可以通过一些变通方法来实现.看看这个链接.

It seams that it´s indeed possible with some workarounds. Take a look at this link.

这篇关于客户端可以仅使用 websockets 直接连接到 SignalR 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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