.NET 4.5 WebSockets 与 SignalR [英] .NET 4.5 WebSockets vs SignalR

查看:31
本文介绍了.NET 4.5 WebSockets 与 SignalR的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到 signalR vs html5 websocketsasp.net MVC 聊天应用程序,但它并不能 100% 回答我的问题,因为它基于 HTML5 WebSockets,Microsoft 可能在 .NET 4.5 中使用其 WebSocket 对象对其进行了扩展.

I've seen signalR vs html5 websockets for asp.net MVC chat application but it doesn't 100% answer my question as it's based around HTML5 WebSockets, which Microsoft may have extended upon in .NET 4.5 with their WebSocket object.

我想知道 WebSocket 功能是否真的与 SignalR 相同并在 WebSockets 不可用时回退到长轮询?微软肯定会采用与 SignalR 相同的技术来处理这项技术吗?

I'm wondering if the WebSocket feature does actually do the same as SignalR and fall back to long polling when WebSockets aren't available? Surely Microsoft would implement the same technology as SignalR in their approach to this technology?

对于其他对此感到疑惑的人,我发现此评论最有助于理解该场景以及我将使用 SignalR 的原因:

For anyone else wondering about this, I found this comment the most helpful to understand the scenario and why I'll be using SignalR:

嗯,他们不是真的.直到现在 IIS 和 ASP.NET 还没有任何内置的支持 WebSockets 的东西,所以 SignalR 项目必须自己建造.现在微软正在提供管道SignalR 可以轻松切换到使用 Microsoft 的实现,除了或代替他们自己.SignalR 是一个对实现细节的抽象,WebScockets 类是实现细节

Well, they are not really. Up until now IIS and ASP.NET didn't have anything built in that supported WebSockets so SignalR project had to build it themselves. Now that Microsoft is providing the plumbing SignalR could easily switch to using Microsoft's implementation, either in addition to or instead of their own. SignalR is an abstraction over implementation details, WebScockets class is the implementation detail

推荐答案

我想知道 WebSocket 功能是否真的与 SignalR 一样并在 WebSockets 不可用时回退到长轮询?

I'm wondering if the WebSocket feature does actually do the same as SignalR and fall back to long polling when WebSockets aren't available?

WebSockets 是一种独立于其他通信技术的新协议.来自 RFC

WebSockets is a new protocol independent of other communication techniques. From the RFC

这项技术的目标是提供一种基于浏览器的机制需要与服务器进行双向通信的应用程序不依赖于打开多个 HTTP 连接(例如,使用XMLHttpRequest 或 s 和长轮询).

The goal of this technology is to provide a mechanism for browser-based applications that need two-way communication with servers that does not rely on opening multiple HTTP connections (e.g., using XMLHttpRequest or s and long polling).

  • 微软肯定会在他们的技术方法中实施与 SignalR 相同的技术吗?

    Surely Microsoft would implement the same technology as SignalR in their approach to this technology?

    如果他们想符合规范,他们就不会.当然,没有什么能阻止微软开发类似于 SignalR 的更高级别的 API,它可以抽象出通信细节并提供优雅的回退.然而,假设的 API 可能建立在 WebSocket 类而不是替换它.

    Not if they want to conform to the specification they won't. There's certainly nothing stopping Microsoft from developing a higher level API similar to SignalR that would abstract away communication detail and offer graceful fallback. However that hypothetical API would probably build on top of WebSocket class as opposed to replacing it.

    这篇关于.NET 4.5 WebSockets 与 SignalR的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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