Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

calling the Caller method in SignalR hub outside the hub context

I have a question in my mind about the Caller method of SignalR. In the hub method we can call a client side function like this.

Clients.Caller.addContosoChatMessageToPage(name, message);

but when i use to call it from outside the hub context it is not found or not implemented?? like this..

 var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
 context.Clients.Caller.reportProgress(recordCount,totalCount);

Can someone enlighten me in this part or is there other way to implement it.. by now i use to implement this

 var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>();
 context.Clients.User(CurrentUser.Usernm).reportProgress(recordCount,totalCount);

but now we are not claim based authentication so it will be a problem if the same usernm are logged..

like image 224
Edu Cielo Avatar asked Feb 12 '15 02:02

Edu Cielo


People also ask

Is SignalR peer to peer?

You can configure the Telerik UI Chat component for ASP.NET MVC and a SignalR 2 service to create a Peer-to-Peer Chat application. To create the Peer-to-Peer Chat, you have to implement the SignalR Hub server and then to implement the application client: Create the new application.

How do I send a message to a group in SignalR?

Group(message. Group). addMessage("Group Message " + message. Msg); it should be message.


1 Answers

Outside of the hub, there obviously is no caller because the server is the one who initiates.

If you are worried about unique user names, you'll need to implement a custom IUserIdProvider, or you need to manage connection ids per user in some other way. Then you could call

context.Clients.Client(connectionId).reportProgress();

which would be unique.

like image 110
Lars Höppner Avatar answered Sep 28 '22 10:09

Lars Höppner