From f32212d160f5427a56b5b8e0219206930c518b64 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 7 Dec 2013 10:52:38 -0500 Subject: update to service stack v4 --- .../HttpServer/NativeWebSocket.cs | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs') diff --git a/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs b/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs index a40dff5a4..ff822a4e6 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs @@ -184,5 +184,41 @@ namespace MediaBrowser.Server.Implementations.HttpServer /// /// The on receive. public Action OnReceive { get; set; } + + /// + /// The _supports native web socket + /// + private static bool? _supportsNativeWebSocket; + + /// + /// Gets a value indicating whether [supports web sockets]. + /// + /// true if [supports web sockets]; otherwise, false. + public static bool IsSupported + { + get + { +#if __MonoCS__ + return false; +#else +#endif + + if (!_supportsNativeWebSocket.HasValue) + { + try + { + new ClientWebSocket(); + + _supportsNativeWebSocket = true; + } + catch (PlatformNotSupportedException) + { + _supportsNativeWebSocket = false; + } + } + + return _supportsNativeWebSocket.Value; + } + } } } -- cgit v1.2.3