Search code examples
asp.net-coresignalrasp.net-core-signalrasp.net-core-2.1

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


Solution

  • 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