在C#客户端和Web客户端中 - 如何告诉signalR - “尝试所有但 websockets”?
我的网络代码中包含以下内容:
window.hubReady = $.connection.hub.start({ transport: 'longPolling' });
但这只是javascript和longpolling;我正在寻找JS和C#客户端的配置,只删除websockets作为传输。怎么办呢?
答案 0 :(得分:3)
在服务器上:
public class Startup
{
public void Configuration(IAppBuilder app)
{
DisableWebSockets(GlobalHost.DependencyResolver);
HubConfiguration hubConfiguration = new HubConfiguration();
hubConfiguration.EnableDetailedErrors = true;
app.MapSignalR(hubConfiguration);
}
public static void DisableWebSockets(IDependencyResolver resolver)
{
var manager = resolver.Resolve<ITransportManager() as TransportManager;
manager.Remove("webSockets");
}
}
在客户端:
$.connection.hub.start({ transport: ['serverSentEvents', 'foreverFrame', 'longPolling'] }).done(function () {...}
编辑 - 添加括号