signalR核心定义传输 [英] signalR core define transport

查看:163
本文介绍了signalR核心定义传输的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在signalR核心最终发布之前。我在定义新的HubConnection(JavaScript)时能够发送传输

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.

推荐答案

这是一个改编自 HubConnectionBuilder.test.ts

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

withUrl 也接受 IHttpConnectionOptions 所以这也可行:

withUrl also accepts IHttpConnectionOptions so this would work too:

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

这篇关于signalR核心定义传输的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆