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
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.
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.
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.
SignalR supports full duplex communication that allows the client and server to transfer data back and forth.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With