To use DI you have to "manually inject" hub context as I described it here. For using typed client it's sufficient to use IHubContext in your case. The content or Web page is downloaded from the Web server and the user can interact with this content in a Web browser, which acts as a client. in it's turn contains the following IHubContext declarations // for untyped hubĪs you can see in this case the interfaces don't contain THub parameter and it's not needed because ASP.NET MVC doesn't have built in DI for SignalR. A Web user interface or Web app allows the user to interact with content or software running on a remote server through a Web browser. contains IHubContext for untyped hub public interface IHubContext where THub : HubĪnd for typed hub public interface IHubContext where THub : Hub where T : classĪs you can see from declarations the THub parameter isn't used anywhere and in fact it exists for dependency injection purposes only. So, I am wondering if it is possible to a DI library or method. However, there is no IHubContext Interface in library and I for this reason I cannot use IHubContext with two parameters ( IHubContext _chatHubContext ). Public DemoController(IHubContext chatHubContext) Inject your the typed hubcontext into your controller, and work with it: public class DemoController : Controller Public void Send(string name, string message)Ĭ(name, message) Inherit from Hub: public class ChatHub : Hub Task BroadcastMessage(string name, string message) You must have a Signal Sciences account to be able to access the web interface controls. I have been trying to used the following approach in my ASP.NET MVC project where library is used: public interface ITypedHubClient The Signal Sciences platform provides web interface access to all of its features and functions, which are also accessible using the application programming interface (API).
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |