Suppose I have a SignalR client-server scenario and I want to manually activate a method on the server and also have some feedback from it. Suppose my javascript code is:
myHub.server.doStuff()
and my C# code is:
public void DoStuff()
{
// some stuff gets done and it can be successful or not.
}
If I was to do an AJAX request I would be able to get info on the result of the action from the http response. Is there a possibility to have this behavior in SignalR, something like this?
myHub.server.doStuff(function callback(response) { // handle response.. })
The most I could think of was having an additional method on the client which would get called from the server when it knows the result, something like:
myHub.client.doStuffCallback = function (result) { // interpret the result }
However this method does not seem secure, plus I would have to have a very safe mechanism of correlating "responses" with "requests". Can SignalR be used in a way similar to what I am describing?