Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR send vs invoke

Using ie the javascript client I can either use

connection.invoke("SendMessage", user, message)

or

connection.send("Send", message);
  • what is the difference between the two ? when to use each ?

  • as a side question, where is the SignalR javascript API documented ? all I can find is this

like image 343
kofifus Avatar asked Jun 15 '18 01:06

kofifus


People also ask

Is SignalR two way communication?

SignalR uses Web Sockets and the HTML5 API that helps in bidirectional communication. It also provides an API for server-to-client Remote Procedure Calls (RPC) call, it may be something new for you because most of the time we use a request and response model.

How do I send client specific messages using SignalR?

We change the BroadcastChartData() method to accept connectionId as an additional parameter. This way, we can find the client using the connectionId and send a message just to that client. Additionally, we add a new GetConnectionId() method, which returns the connectionId of the client.

Does SignalR require sticky session?

SignalR requires that all HTTP requests for a specific connection be handled by the same server process. When SignalR is running on a server farm (multiple servers), "sticky sessions" must be used. "Sticky sessions" are also called session affinity by some load balancers.

Is SignalR full duplex?

SignalR supports full duplex communication that allows the client and server to transfer data back and forth.


1 Answers

You need to read the source code to see the difference between send and invoke.

Send returns a promise that is resolved when the client has sent the invocation to the server, or an error occurred. The server may still be handling the invocation when the promise resolves.

Invoke returns a promise that is resolved when the server has finished invoking the method (or an error occurred). In addition, the Invoke promise can receive a result from the server method, if the server returns a result.

The code can be found here

The only official documentation I have found for the JS client was here

like image 177
Simply Ged Avatar answered Sep 25 '22 00:09

Simply Ged