代码之家  ›  专栏  ›  技术社区  ›  umutesen

带角度的singlerr:如何指定传输类型

  •  1
  • umutesen  · 技术社区  · 7 年前

    我在我的角度应用程序中使用来自npm的信号器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 回复  |  直到 7 年前
        1
  •  0
  •   Chris Pratt    7 年前

    withUrl 具有将 signalR.HttpTransportType 枚举:

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