SinglarR with Angular:如何指定传输类型

时间:2018-06-06 13:57:31

标签: asp.net-core-2.0 signalr.client angular6

我在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');
      });

如何指定传输类型,例如,长轮询?

1 个答案:

答案 0 :(得分:0)

withUrl有一个重载,它带有signalR.HttpTransportType枚举的成员:

.withUrl(`${environment.apiUrl}operations?token=${this.user.token}`, signalR.HttpTransportType.LongPolling)