question

6666666 avatar image
0 Votes"
6666666 asked 6666666 commented

cannot use strongly-typed hubs in signalr?

I created a interface

 public interface IOrder
 {
     Task StartingFailed(string message);
 }

and create Hub:

 public class MyHub:Hub<IOrder>
 {
     public async Task CreateOrder()
     {
           //here I can not use Clients
          //Clients is not found why?
      }
    
 }



dotnet-aspnet-signalr
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

YijingSun-MSFT avatar image
0 Votes"
YijingSun-MSFT answered 6666666 commented

Hi @6666666 ,

Do you have get or set an object that can be used to call methods on clients connected to this hub?
You need to use Hub. Clients property.

More details,you could refer to below articles:
https://docs.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.signalr.hub.clients?view=aspnetcore-5.0
https://docs.microsoft.com/en-us/aspnet/core/signalr/hubs?view=aspnetcore-5.0#:~:text=What%20is%20a%20SignalR%20hub%20The%20SignalR%20Hubs,define%20methods%20that%20are%20called%20from%20the%20server.+/

Best regards,
Yijing Sun


If the answer is helpful, please click "Accept Answer" and upvote it.

Note: Please follow the steps in our  documentation  to enable e-mail notifications if you want to receive the related email notification for this thread.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The page can not be open.

and I can not understand what you means.

0 Votes 0 ·

Hi @6666666 ,
I have update my articles' link on below reply.
Best regards.
Yijing Sun

0 Votes 0 ·
6666666 avatar image 6666666 YijingSun-MSFT ·

I find that it can not use on partial class right?

if one partial class can not use hub<T> I have to write all methods into one class.

0 Votes 0 ·