如何使用 ASP.Net、IISNode、Node.JS 和 SQL Server 实现基于事件的推送通知的 Socket.IO?

编程入门 行业动态 更新时间:2024-10-12 05:54:04
本文介绍了如何使用 ASP.Net、IISNode、Node.JS 和 SQL Server 实现基于事件的推送通知的 Socket.IO?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于通知项目,希望将事件通知推送出去.这些是登录、个人资料更改等内容,并将显示给适当的客户.我想讨论一些关于将其组合在一起的想法,并就最佳方法获得一些建议.

For a notification project, would like to push event notifications out. These are things like login, change in profile, etc., and to be displayed to the appropriate client. I would like to discuss some ideas on putting it together, and get some advice on the best approach.

我注意到这里可以使用 _changes 流检测 CouchDB,由 Node 拾取,然后启动一个进程.我想实现这样的东西(我正在使用 SQL Server,但这个级别的入口点可能不是最好的解决方案).

I noticed here that changes made to a CouchDB can be detected with a _changes stream, picked up by Node, and a process kicks off. I would like to implement something like this (I'm using SQL Server, but an entry point at this level may not be the best solution).

我没有遵循 CouchDB 示例(检测基于数据库的事件,我认为这只会使事情复杂化,因为我们对客户端事件感兴趣),我认为当事件发生时,例如用户登录,然后带有一些事件详细信息(RESTful 请求?)的消息被发送到节点服务器.然后处理此消息并将其广播给所有连接的客户端;相应的客户端显示通知.

Instead of following the CouchDB example (detecting database-based events, I think this just complicates things, since we're interested in client events), I was thinking that when an event occurs, such as a user login, then a message is sent to the Node server with some event details (RESTful request?). This message is then processed and broadcast to all connected clients; the appropriate client displays notification.

提议的生态系统:

.Net 4.0IISIIS节点Socket.IONode.JSSQL Server 2008

这将建立在使用 .Net 框架(IIS 等)的现有项目之上.许多客户端的浏览器不支持 Web 套接字,因此使用 Socket.IO 是一个不错的选择(后备支持).但是,从 我可以看到,Socket.IO 仍然只支持通过 IISNode 进行长轮询(这不是一个真正的问题).

This will be built on top of an existing project using the .Net framework (IIS, etc.). Many of the clients' browsers do not support web sockets, so using Socket.IO is a good option (fallback support). However, from what I can see, Socket.IO only still only supports long polling through IISNode (which isn't really a problem).

一个选项是向所有客户端公开 Socket.IO/Node 端点,以便可以通过 JS 将基于客户端的通知发送到广播消息的 Node 服务器.(遵循基本的聊天服务器/客户端/服务器示例).

An option would be to expose the Socket.IO/Node endpoint to all clients, so that client-based notifications can be sent through JS to the Node server, which broadcasts the message. (follows the basic chat-server /client/server examples).

或者,可以使用 IIS 端点,但只能支持长轮询(通过 Socket.IO).这将提供一些额外的 .Net 后端处理,但可能会使架构过于复杂.

Alternately, an IIS endpoint could be used, but could only support long polling (through Socket.IO). This would offer some additional .Net back-end processing, but may be over-complicating the architecture.

Node 是否有基于 SQL Server 的事件通知?

Is there SQL Server-based event notification available for Node?

最好的方法是什么?

如果我的术语生态系统配置不正确,请澄清.

If I didn't get the terminology ecosystem configuration right, please clarify.

谢谢.

推荐答案

我建议你看看 SignalR 首先在考虑将 iisnode/node.js 添加到现有 ASP.NET 应用程序的技术组合中.

I would recommend you check out SignalR first before considering adding iisnode/node.js to the mix of technologies of your pre-existing ASP.NET application.

关于 websockets,无论你使用 ASP.NET 还是 node.js (socket.io),你只能使用 HTTP 长轮询来获得低延迟通知,因为在 Windows 8 之前 HTTP.SYS/IIS 不支持 websockets.iisnode 当前不支持 websockets(即使在 Windows 8 上),但以后可能会添加此类支持.

Regarding websockets, regardless if you use ASP.NET or node.js (socket.io), you can only use HTTP long polling for low latency notifications, as websockets are not supported by HTTP.SYS/IIS until Windows 8. iisnode does not currently support websockets (even on Windows 8), but such support could be added later.

我最近做了一些关于从 node.js 访问 MSSQL 的研究.有一些 OSS 项目,其中一些使用本地的、特定于平台的扩展,一些尝试纯粹在 JavaScript 中实现 TDS 协议.我不知道任何可以让您访问 SQL 通知功能的东西.但是,MSSQL 团队本身正在为 node.js 投资一流的 MSSQL 驱动程序,因此这是需要密切关注的事情(https://github/tjanczuk/iisnode/issues/139).

I did some research lately regarding MSSQL access from node.js. There are a few OSS projects out there, some of them use native, platform-specific extensions, some attempt implementing TDS protocol purely in JavaScript. I am not aware of any that would enable you to access the SQL Notifications functionality. However, the MSSQL team itself is investing in a first class MSSQL driver for node.js, so this is something to keep an eye on going forward (https://github/tjanczuk/iisnode/issues/139).

如果您计划使用 SQL 通知来支持低延迟通知,我强烈建议您从在 SQL 服务器级别模拟所需流量级别的性能基准开始.SQL 通知主要是作为一种机制来帮助在内存中保持与数据库内容一致的缓存,因此它可能满足也可能不满足通知场景的要求.这些测量至少可以帮助您从更好的设计开始.

If you plan to use SQL Notifications to support low latency notifications, I would strongly recommend starting with performance benchmarks that simulate the desired level of traffic at the SQL server level. SQL Notifications were meant primarily as a mechanism to help maintain in memory cache consistent with the content of the database, so it may or may not meet the requirements of your notification scenario. At the very minimum these measurements would help you start with a better design.

这篇关于如何使用 ASP.Net、IISNode、Node.JS 和 SQL Server 实现基于事件的推送通知的 Socket.IO?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-03-19 00:35:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/625753.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   事件   通知   Net   IISNode

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!