如何连接没有SignalR客户端库的signalR集线器?

时间:2019-05-02 16:51:36

标签: javascript c# ios signalr

我正在开发一个带有asp net Core后端的iOS应用。我需要在应用程序流程的某个位置创建实时连接,我在后端API上实现了SignalR,使用官方的TS SignalR客户端没有问题。但是我无法使用纯TSClient从中心接收消息。

connectJs() {
    this.http
      .post<any>('http://localhost:8083/testhub/negotiate', null)
      .subscribe(x => {
        const id = x.connectionId;

        this.ws = new WebSocket('ws://localhost:8083/testhub?id=' + id);

        this.ws.onopen = () => {
          console.log('open');
        };

        this.ws.onerror = function(error) {
          console.log(error);
        };

        this.ws.onmessage = data => {
          console.log(data);
        };
      });
  }

打开已打印,但是当我从后端向所有客户端发送消息时:

await _hubContext.Clients.All.SendAsync("test", "HELLO WORLD", true);

什么也没收到。

0 个答案:

没有答案