Vic*_*orV 10 asp.net-core-signalr
嗨,我正在使用角度应用程序连接到信号器,我正在使用"@ aspnet/signalr":"1.0.0-preview1-final".
我需要将connectionId发送到我的控制器(我需要做一些进程并告诉所有其他客户端但没有用户发出请求),问题是Connection Id是私有的,有办法获取连接ID吗?
aar*_*ron 15
看起来像XY问题.
毂:
public async Task TellAllOtherClients(object[] args)
{
await Clients.Others.SendAsync("method", args);
}
Run Code Online (Sandbox Code Playgroud)
connectionId(解决方案Y)毂:
public string GetConnectionId()
{
return Context.ConnectionId;
}
Run Code Online (Sandbox Code Playgroud)
客户:
hub.invoke('getConnectionId')
.then(function (connectionId) {
// Send the connectionId to controller
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2995 次 |
| 最近记录: |