带有 ASP.NET MVC / MVVM 的 Websocket
今天早些时候,我遇到了 Kaazing 的 HTML5 WebSocket API。
看起来棒极了,但由于我现在才研究 WebSocket 实时财务更新的可能性,我想听到一些建议,以及在规划此架构时要避免的陷阱。
我正在研究 ASP.Net MVC,可能还有一些 WPF/Silverlight MVVM。
是否还有其他更好的 WebSocket API(以及原因)以及一些很好的示例?
另外,WebSockets 可以处理什么样的流量?我的意思是,如果我们的系统上有超过 100 万用户实时更新,那么由于软件架构实现了 WebSockets,硬件要求会如何变化?
Earlier today I came across Kaazing's WebSocket API for HTML5.
Looks fantastic, but as I am only now researching WebSocket possibilities for real-time financial updating, I would like to hear some recommendations, and pitfalls to avoid when planning out this architecture.
I'm looking at ASP.Net MVC, and possibly some WPF/Silverlight MVVM.
Are there other WebSocket API's that are better (and why), and some good examples?
Also, what kind of traffic can WebSockets handle? I mean, if we have over a million users on a system updating real-time, how do hardware requirements change because the software architecture implements WebSockets?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
迟到的答复。这是一个基于 .NET 的 WebSocket 服务器(框架),以类似于 MVC 的方式支持模型绑定/控制器和验证等。开始使用它非常容易。只需创建一个新的 MVC3 项目并输入:
Install-Package XSockets
使用 Visual Studio 中的包管理器控制台
有关 http://xsockets.net 的更多信息
以及是的,它支持 RFC6455 和 Hibi00,并且有“旧”浏览器的后备功能。
A late answer. Here is a WebSocket Server (framework) that is based on .NET and has support for modelbinding / controller and validations etc. in a way that reminds of MVC. It is very easy to get started using it. Just create a new MVC3 Project and type:
Install-Package XSockets
Using the Package Manager Console in Visual Studio
More info on http://xsockets.net
And yes, it supports RFC6455 and Hibi00 and has a fallback for "older" browsers.
我想既然我已经有了一个可以用于生产的解决方案,我就应该回来讨论这个问题。我看了一些供应商,他们基本上对你可以自己构建的东西收取很高的费用。他们都有很好的产品,如果您的上市时间很关键,那么这些预制件选择可能是短期内最好的选择。
在研究了 Node.JS 和 Socket.IO 之后,我将注意力转移到 SignalR - 一个异步信号库.NET 帮助构建实时、多用户交互式 Web 应用程序,并使用了集线器实现。
它只需几行 JavaScript 即可管理所有繁重的工作和连接构建,并自动为连接选择适当的传输协议。
对于负载均衡的环境,需要实现Redis等缓存服务器。
I figured I'd come back at this, now that I have a solution ready for production. I took a look at a few vendors that basically charge a lot of money for something you can essentially build yourself. They all have good products, and if your time to market is critical, those prefab options may be the best in the short run.
After poking around with Node.JS with Socket.IO, I shifted my attention to SignalR - an asynchronous signaling library for .NET to help build real-time, multi-user interactive web applications, and used the hub implementation.
It manages all the heavy lifting and connection building with just a few lines of JavaScript, and automatically selects the appropriate transport protocol for the connection.
For a load-balanced environment, implementation of a caching server such as Redis is required.
以下是 CodeProject 上 Web Socket 客户端和服务器的 C# 实现:
Web Socket 服务器
Here's a C# implementation of a Web Socket client and server on CodeProject:
Web Socket Server
我认为以下链接会对您有所帮助..
Silverlight 的 WebSockets 原型、HTML Bridge 和 JavaScript
Silverlight 和 WebSockets(Mike Taulty 的博客)
I think following links will help you..
The WebSockets prototype with Silverlight, HTML Bridges and JavaScript
Silverlight and WebSockets (Mike Taulty's blog)
https://github.com/Olivine-Labs/Alchemy-Websockets
这是一个开源的websocket 服务器和客户端库。 C#/Javascript。包括针对尚无 Websocket 的浏览器的 Flash 套接字回退。在大多数网络浏览器(包括移动浏览器)上进行了测试,适用于任何地方。
实时财务?我不知道您计划处理多少个连接,但这也是目前可用的最具可扩展性的解决方案。
https://github.com/Olivine-Labs/Alchemy-Websockets
Here's an open source websocket server and client library. C#/Javascript. Includes fallback to flash sockets for browsers that don't have websockets yet. Tested on most web browsers including mobile ones, works everywhere.
Realtime financials? I don't know how many connections you plan on handling but this one is also the most scalable solution available right now.
尽管支持 websocket 的浏览器数量非常有限,但移动浏览器对此提供了支持。但我会考虑使用更多跨浏览器友好的选择,例如 PokeIn 反向 ajax 库
Although the number of browsers are quite limited for websockets, mobile browsers have support for that. But i would be considering the use of more cross browser friendly choices like PokeIn reverse ajax library