signalR core define transport

2019-03-02 23:01发布

Before the final release of signalR core. I was able to send the transport when defining a new HubConnection (JavaScript)

var cnn = new signalR.HubConnection("/myhub", 
                                         {transport : signalrR.TransportType.LongPolling});

this doesn't work anymore. And i was not able to find any documentation / sample yet.

A sample or a link to the documentation would be much appreciated.

1条回答
smile是对你的礼貌
2楼-- · 2019-03-02 23:11

Here is a sample adapted from HubConnectionBuilder.test.ts:

const builder = new signalR.HubConnectionBuilder()
    .withUrl("/myhub", signalR.HttpTransportType.WebSockets)
    .build();

withUrl also accepts IHttpConnectionOptions so this would work too:

const builder = new signalR.HubConnectionBuilder()
    .withUrl("/myhub", { transport: signalR.HttpTransportType.WebSockets })
    .build();
查看更多
登录 后发表回答