SinglarR с Angular: как указать тип транспорта - PullRequest
0 голосов
/ 06 июня 2018

Я использую signalr 1.0.0-rc1-update1 из npm в моем приложении Angular.

Вот как я сейчас подключаюсь к концентратору:

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 голосов
/ 06 июня 2018

withUrl имеет перегрузку, которая принимает член перечисления signalR.HttpTransportType:

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