Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to receive return values from a SignalR message?

Tags:

People also ask

Does SignalR guarantee delivery?

SignalR doesn't guarantee message delivery. Since SignalR doesn't block when you call client methods, you can invoke client methods very quickly as you've discovered. Unfortunately, the client might not always be ready to receive messages immediately once you send them, so SignalR has to buffer messages.

Is SignalR bidirectional?

ASP.NET SignalR is a new library for ASP.NET developers that makes developing real-time web functionality easy. SignalR allows bi-directional communication between server and client. Servers can now push content to connected clients instantly as it becomes available.

Does SignalR keep connection alive?

If the client goes into reconnecting mode, and if the server recovers or restarts or a new server is brought online before the disconnect timeout period expires, the client will reconnect to the restored or new server. In that case, the SignalR connection continues on the client and the Reconnected event is raised.


I`m calling SignalR from inside a MVC Controller action

var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>(); var ret = context.Clients.Client("Whatever").getValue(userId); 

Is there anyway I can get a response from the getValue() method being called on the Client inside the action?

I've tried a few ways but simply can't get any value for ret. I'm pretty sure this doesn't work with a SignalR Hub but couldn't find documentation about this.

One solution I've considered is after receiving the getValue the Client would call a method in the Hub but then I would have to hack my way into getting the response from the Hub into the controller.