我在Angular应用程序中使用来自npm的signalr 1.0.0-rc1-update1。
这就是我目前连接到集线器的方式:
this.hub = new signalR.HubConnectionBuilder()
.withUrl(`${environment.apiUrl}operations?token=${this.user.token}`)
.configureLogging(signalR.LogLevel.Trace)
.build();
this.hub.on('GetOperations', (data: OperationGetDto[]) => {
this.data = data;
});
this.hub.start()
.then(() => {
this.hub.invoke('GetOperations');
})
.catch((e) => {
this.notificationService.openSnackBar('Error while establishing connection');
});
如何指定传输类型,例如,长轮询?
答案 0 :(得分:0)
withUrl
有一个重载,它带有signalR.HttpTransportType
枚举的成员:
.withUrl(`${environment.apiUrl}operations?token=${this.user.token}`, signalR.HttpTransportType.LongPolling)