Is there any way to do something like this in SignalR:
public void CallClientMethod(string methodName, MyObject data)
{
var ctx = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
ctx.Clients.All.methodName(data);
// or alternatively
ctx.Clients.All.CallClientMethod(methodName, data);
}
The above example illustrates the intent, rather than the actual mechanism - I want to determine the method to call at runtime, rather than compile time.
You can do this:
public void CallClientMethod(string methodName, MyObject data)
{
var ctx = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
IClientProxy proxy = ctx.Clients.All;
proxy.Invoke(methodName, data);
}
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