Node.Js + Socket.IO vs SignalR vs C# WebSocket 服务器 [英] Node.Js + Socket.IO vs SignalR vs C# WebSocket Server
问题描述
我目前有一个用 .Net 编写的 TCP 服务器应用程序,用于接收和提交消息给客户端.我正在考虑构建一个 Web 应用程序,因此需要通信层.
I currently have a TCP server application written in .Net that receives and submits messages to clients. I am looking at building a web application so need the communication layer.
我已经构建了一个 Node.JS + Socket.IO 应用程序,它连接到我的 TCP 服务器,然后将通信推送到 Web 应用程序并且一切正常.
I have built a Node.JS + Socket.IO app which connects to my TCP server and then pushes communication to the web application and all works fine.
我刚刚阅读了 SignalR 作为将其保留在 .Net 堆栈中的替代方法.
I have just read about SignalR as an alternative to keep it in the .Net stack.
但是我也发现我可以写一个 C# Websocket 服务器,一个基本的演示 here
However I have also found that I could write a C# Websocket Server, a basic demo here
我认为这个基本服务器就是 SignalR,但显然其中包含更多功能?
I assume that this basic server is what SignalR is but obviously with a lot more functionality in it?
我要决定的是,我是将当前的 TCP 应用程序附加到 Websocket 服务器,还是使用单独的 SignalR 或 Node.js 路由?出于对 SignalR 应用程序如何运行的兴趣,它是作为 Windows 服务、控制台应用程序还是 IIS 服务?
What I'm trying to decide is do I just append my current TCP application with a Websocket server or do I go down a separate SignalR or Node.js route? Out of interest how does a SignalR application run, is it as a Windows service, console app or IIS service?
推荐答案
SignalR 类似于 Socket.IO,因为它支持传输协商/回退.它是一个框架而不是服务器,因此您需要将它托管在某种服务器上.我们有适用于 ASP.NET、OWIN(例如 Kayak)和自托管的主机,因此您可以轻松地在自己的进程中运行它,例如Windows 服务.
SignalR is like Socket.IO in that it supports transport negotiation/fallback. It is a framework and not a server, so you need to host it on a server of some sort. We have hosts for ASP.NET, OWIN (e.g. Kayak) and self-host, so you can run it in your own process easily, e.g. a Windows service.
SignalR 已支持浏览器 (JS)、.NET、Windows Phone 7 和 Silverlight 的客户端.也有为 iOS、Mono Touch 等提供的客户端.
SignalR has supported clients for browsers (JS), .NET, Windows Phone 7 and Silverlight. There are also contributed clients for things like iOS, Mono Touch, etc.
SignalR 将为您提供比原始套接字更高级别的 API,这是它的一大优势,允许您以广播(或定向)方式执行从服务器到客户端的RPC"等操作.
SignalR will give you a much higher level API than raw sockets which is its big advantage, allowing you to do things like "RPC" from server to clients in a broadcast (or targeted) fashion.
这篇关于Node.Js + Socket.IO vs SignalR vs C# WebSocket 服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!