Reputation: 41579
Is it possible to explicity set two (or more) transports in the SignalR .Net Client?
I can set a single transport using code such as:
_hubCn.Start(new LongPollingTransport());
In the Javascript client it can be done using:
connection.start({ transport: ['webSockets','longPolling'] });
However I haven't found an overload on the .Net client that allows for this. Is there some other way?
For a little bit of context, this particular usage is within a Silverlight 5 application. I'm still exploring what differences this makes over normal .Net or JS uses.
Upvotes: 1
Views: 3768
Reputation: 2696
Use AutoTransport:
var httpClient = new DefaultHttpClient();
_hubCn.Start(new AutoTransport(httpClient,
new IClientTransport[]
{
new WebSocketTransport(httpClient),
new LongPollingTransport(httpClient)
}));
As documented in the source code the list you provide is a:
List of transports in fallback order
Upvotes: 3
Reputation: 31620
If you don't provide a transport when you start a connection with the .Net client it will use so called AutoTransport
which basically will try different transports until it finds one that works. Note that depending on the platform (e.g. .NET Framework vs. Silverlight/Portable) the list of transports available to the AutoTransport may be different (currently you will get WebSockets, ServerSentEvents and LongPolling on .NET and ServerSentEvents and LongPolling on Portable). However if you want to exclude (or add - e.g. there is a Windows Phone 8.1 (universal app) specific implementation of WebSocket transport) a transport you can manually create an AutoTransport
and provide transports you want to use.
Upvotes: 1