Reputation: 4433
I am looking to start a project in which I need to make push updates from Web API.
I found this post which gives an example of how to do this.
Can I incorporate both SignalR and a RESTful API?
http://bradwilson.typepad.com/blog/2012/07/webstack-of-love.html
This demo uses a class called ApiControllerWithHub<THub>
You extend your web api controllers from this.
This post is quite old now (2013). Is this still the correct way to do things or have there been developments in Web API to allow for push updates?
Upvotes: 1
Views: 472
Reputation: 6375
I don´t think there´s a new integration between web api controllers and hubs. That code is totally fine.
The key part is:
Lazy<IHubContext> hub = new Lazy<IHubContext>(
() => GlobalHost.ConnectionManager.GetHubContext<THub>()
);
You can implement that code the way you want. But the sample code is a nice way to use it.
Upvotes: 2