嗨,我正在使用角度应用程序连接到信号器,我正在使用“@ aspnet / signalr”:“1.0.0-preview1-final”.
@H_502_2@我需要将connectionId发送到我的控制器(我需要做一些进程并告诉所有其他客户端但没有用户发出请求),问题是Connection Id是私有的,有办法获取连接ID吗?
解决方法
好像是
XY problem.
@H_502_2@告诉所有其他客户(问题X)
@H_502_2@毂:
public async Task TellAllOtherClients(object[] args) { await Clients.Others.SendAsync("method",args); }@H_502_2@获取connectionId(解决方案Y) @H_502_2@毂:
public string GetConnectionId() { return Context.ConnectionId; }@H_502_2@客户:
hub.invoke('getConnectionId') .then(function (connectionId) { // Send the connectionId to controller });