如何使用ASP.Net,IISNode,Node.JS和SQL Server实现基于事件的推送通知的Socket.IO? [英] How to implement Socket.IO with ASP.Net, IISNode, Node.JS, and SQL Server for event-based push notifications?

查看:106
本文介绍了如何使用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.0
  • IIS
  • IISNode
  • Socket.IO
  • Node.JS
  • SQL 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服务器,该服务器广播消息. (遵循基本的聊天服务器/client/server示例).

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.

关于websocket,无论使用ASP.NET还是node.js(socket.io),都只能对低延迟通知使用HTTP长轮询,因为直到Windows 8才支持HTTP.SYS/IIS的websocket. iisnode当前不支持websocket(即使在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驱动程序,因此这是需要密切注意的事情(

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.com/tjanczuk/iisnode/issues/139).

如果您打算使用SQL通知来支持低延迟通知,我强烈建议您从性能基准开始,该基准在SQL Server级别模拟所需的通信量. SQL Notifications主要是作为一种机制来帮助维持内存缓存中与数据库内容一致的机制,因此它可能会或可能不会满足您的通知方案的要求.这些测量值至少可以帮助您从更好的设计入手.

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屋!

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