集线器(在 signalR 中使用)和远程过程调用 (RPC) 之间有什么区别?

What is the difference between hub (one used in signalR) and remote procedure calls(RPCs)?

A Hub is one which allows the direct call to client-side and server-side methods as in SignalR(ASP.Net Library).

Remote Procedure Call(RPC) Which calls JS function which is defined on the client from the server code.

所以我的问题是这两者之间有什么区别?

你喜欢比较苹果和橘子

什么是信号器点上的集线器:

集线器是对某些通信层的抽象。您可以从客户端调用集线器上的方法,也可以从服务器调用客户端上的方法。对于集线器内的那个,你有一个客户 属性.

基本上用signalr建立服务器和客户端之间的连接。底层传输机制(长轮询、服务器发送事件、websockets 等)将由 signalr 选择。建立连接后,您可以在客户端中说例如 "call method X on hub Y with parameter Q"。信号器将其发送到服务器之后。在服务器端,集线器调度程序搜索是否存在名称为 Y 且方法为 X 的集线器。此外,方法的签名必须与参数匹配。如果方法匹配,它将被调用。反之亦然

Rpc(来自维基百科):

RPC is a request–response protocol. An RPC is initiated by the client, which sends a request message to a known remote server to execute a specified procedure with supplied parameters. The remote server sends a response to the client, and the application continues its process. While the server is processing the call, the client is blocked (it waits until the server has finished processing before resuming execution), unless the client sends an asynchronous request to the server, such as an XMLHttpRequest. ....

一个很大的不同是,如果客户端不要求,您不能将数据从服务器发送到客户端。