0
votes

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

and

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

So my query is what is the difference between these two?

1
Thanx for editing Sir. @Hans Kesting – Vikramjeet Singh

1 Answers

1
votes

You like to compare apples an oranges

Whats a hub on the point of signalr:

A hub is an abstraction over some communication layers. You can call methods on a hub from clients, and you can also call methods on the clients from server. For that inside a hub you have a clients property.

Basically with signalr establishes a connection between server and client. The underling transport mechansime (long polling, server sent event, websockets,..) will be choosen by signalr. After the connection is established you can say for example in the client "call method X on hub Y with parameter Q". After that signalr sends this to the server. On the server side the hub dispatcher searches if there is a hub with the name Y and the method X. Also the signature of the method must match to the parameters. In the case a method matches it will be called. The same works also the opposite way.

Rpc (From wikipedia):

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. ....

One big different is that you cannont send data from server to client if client do not ask for it.