Can you discern on the server side which transport method is being used for a given SignalR connection? (WebSockets, SSE, long polling, etc.?)
Inside a Hub you can detect the transport being used by looking at the request's query string:
Context.QueryString["transport"]
This will evaluate to "webSockets", "serverSentEvents", "foreverFrame" or "longPolling".
Ideally your code should not depend on which transport is being used since SignalR abstracts that for you. However, this could be useful for logging and such.
For ASP.NET SignalR version 2.0, you can use $.connection.hub.transport.name
to print out the name of the transport. It will evaluate to "serverSentEvents" and other transports.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With