我正在使用信号R在我的asp点网络应用程序。这里,我使用IHubContext从外部调用客户端到Hub类。我需要获得当前的用户连接id,以便只发送消息给当前被调用的用户。如何解决?
controller
var HubContext = GlobalHost.ConnectionManager.GetHubContext<"ChatHub">(); //`ChatHub` can be your Hub Name
ChatHub HubObj= new ChatHub();
var RequiredId= HubObj.InvokeHubMethod();
hub
public string InvokeHubMethod()
{
return "ConnectionID" //ConnectionID will the Id as string that you want outside the hub
}