1

There are other questions on the topic but the solutions there don't work for me. I guess is a small detail on the syntax since it changes a bit from version to version..

I created a SignalR hub on a blazor hosted WASM, and I want to be able to send messages from my GameController and not only from the hub itself.

My GameHub inherits from Hub, and I to get a hub context to send a message. The nI guet the no valid conversion from GameHub to IHub.

I tried to implement IHub insted of inheriting from Hub but then it ask to implement other methods I have no clue about and I've never seen in other tutorials..

Here's a picture with the error message and the GameHub declaration:

enter image description here

javirs
  • 1,049
  • 26
  • 52

1 Answers1

0

I use IHubContext<...> like this:

public ChatService(IHubContext<ChatHub> chatHub, IStorageService storageService)
{
    this.chatHub = chatHub;
    this.storageService = storageService;
}

This service is provided for injection as well.

Brian Parker
  • 11,946
  • 2
  • 31
  • 41