The Free Software Media System - Server Backend & API
Moved some web socket classes to the model
Luke Pulverentia6c9fdd0f262
diff --git a/MediaBrowser.Common/MediaBrowser.Common.csproj b/MediaBrowser.Common/MediaBrowser.Common.csprojindex 76bf63e3a5..bdef529a57 100644--- a/MediaBrowser.Common/MediaBrowser.Common.csproj+++ b/MediaBrowser.Common/MediaBrowser.Common.csproj@@ -87,8 +87,6 @@<Compile Include="Net\MimeTypes.cs" /><Compile Include="Net\UdpMessageReceivedEventArgs.cs" /><Compile Include="Net\WebSocketConnectEventArgs.cs" />- <Compile Include="Net\WebSocketMessageType.cs" />- <Compile Include="Net\WebSocketState.cs" /><Compile Include="Plugins\IPlugin.cs" /><Compile Include="Plugins\IUIPlugin.cs" /><Compile Include="Progress\ActionableProgress.cs" />diff --git a/MediaBrowser.Common/Net/BasePeriodicWebSocketListener.cs b/MediaBrowser.Common/Net/BasePeriodicWebSocketListener.csindex de5071a53e..a8e8d7a8cd 100644--- a/MediaBrowser.Common/Net/BasePeriodicWebSocketListener.cs+++ b/MediaBrowser.Common/Net/BasePeriodicWebSocketListener.cs@@ -4,6 +4,7 @@ using System.Collections.Generic;using System.Linq;using System.Threading;using System.Threading.Tasks;+using MediaBrowser.Model.Net;namespace MediaBrowser.Common.Net{diff --git a/MediaBrowser.Common/Net/IWebSocket.cs b/MediaBrowser.Common/Net/IWebSocket.csindex 9c9bcb41dd..805340b906 100644--- a/MediaBrowser.Common/Net/IWebSocket.cs+++ b/MediaBrowser.Common/Net/IWebSocket.cs@@ -1,6 +1,7 @@using System;using System.Threading;using System.Threading.Tasks;+using MediaBrowser.Model.Net;namespace MediaBrowser.Common.Net{diff --git a/MediaBrowser.Common/Net/IWebSocketConnection.cs b/MediaBrowser.Common/Net/IWebSocketConnection.csindex 8e1b13ceb9..c09d5ba2bc 100644--- a/MediaBrowser.Common/Net/IWebSocketConnection.cs+++ b/MediaBrowser.Common/Net/IWebSocketConnection.cs@@ -1,6 +1,7 @@using System;using System.Threading;using System.Threading.Tasks;+using MediaBrowser.Model.Net;namespace MediaBrowser.Common.Net{diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csprojindex a3bc341c34..ae6e21923b 100644--- a/MediaBrowser.Model/MediaBrowser.Model.csproj+++ b/MediaBrowser.Model/MediaBrowser.Model.csproj@@ -46,6 +46,8 @@<Compile Include="Dto\ChapterInfoDto.cs" /><Compile Include="Dto\IItemDto.cs" /><Compile Include="Entities\IByReferenceItem.cs" />+ <Compile Include="Net\WebSocketMessageType.cs" />+ <Compile Include="Net\WebSocketState.cs" /><Compile Include="Querying\ItemsByNameQuery.cs" /><Compile Include="Entities\BaseItemInfo.cs" /><Compile Include="Connectivity\ClientConnectionInfo.cs" />diff --git a/MediaBrowser.Common/Net/WebSocketMessageType.cs b/MediaBrowser.Model/Net/WebSocketMessageType.cssimilarity index 87%rename from MediaBrowser.Common/Net/WebSocketMessageType.csrename to MediaBrowser.Model/Net/WebSocketMessageType.csindex 3b12bc2b29..37ae7fc55f 100644--- a/MediaBrowser.Common/Net/WebSocketMessageType.cs+++ b/MediaBrowser.Model/Net/WebSocketMessageType.cs@@ -1,5 +1,5 @@-namespace MediaBrowser.Common.Net+namespace MediaBrowser.Model.Net{/// <summary>/// Enum WebSocketMessageType@@ -17,6 +17,6 @@ namespace MediaBrowser.Common.Net/// <summary>/// The close/// </summary>- Close,+ Close}}diff --git a/MediaBrowser.Common/Net/WebSocketState.cs b/MediaBrowser.Model/Net/WebSocketState.cssimilarity index 95%rename from MediaBrowser.Common/Net/WebSocketState.csrename to MediaBrowser.Model/Net/WebSocketState.csindex 7f8ac3cbe0..41a2e9741d 100644--- a/MediaBrowser.Common/Net/WebSocketState.cs+++ b/MediaBrowser.Model/Net/WebSocketState.cs@@ -1,5 +1,5 @@-namespace MediaBrowser.Common.Net+namespace MediaBrowser.Model.Net{/// <summary>/// Enum WebSocketStatediff --git a/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs b/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.csindex 9f5d14eaf9..9ad6178472 100644--- a/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs+++ b/MediaBrowser.Server.Implementations/HttpServer/NativeWebSocket.cs@@ -4,8 +4,8 @@ using System;using System.Net.WebSockets;using System.Threading;using System.Threading.Tasks;-using WebSocketMessageType = MediaBrowser.Common.Net.WebSocketMessageType;-using WebSocketState = MediaBrowser.Common.Net.WebSocketState;+using WebSocketMessageType = MediaBrowser.Model.Net.WebSocketMessageType;+using WebSocketState = MediaBrowser.Model.Net.WebSocketState;namespace MediaBrowser.Server.Implementations.HttpServer{@@ -83,7 +83,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer}catch (WebSocketException ex){- _logger.ErrorException("Error reveiving web socket message", ex);+ _logger.ErrorException("Error receiving web socket message", ex);break;}diff --git a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.csindex cba74ffbf8..c1453cd8ba 100644--- a/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs+++ b/MediaBrowser.Server.Implementations/ServerManager/ServerManager.cs@@ -3,6 +3,7 @@ using MediaBrowser.Common.Net;using MediaBrowser.Controller;using MediaBrowser.Controller.Configuration;using MediaBrowser.Model.Logging;+using MediaBrowser.Model.Net;using MediaBrowser.Model.Serialization;using System;using System.Collections.Generic;diff --git a/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs b/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.csindex d92c607732..5a074d1947 100644--- a/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs+++ b/MediaBrowser.Server.Implementations/ServerManager/WebSocketConnection.cs@@ -1,5 +1,6 @@using MediaBrowser.Common.Net;using MediaBrowser.Model.Logging;+using MediaBrowser.Model.Net;using MediaBrowser.Model.Serialization;using System;using System.IO;diff --git a/MediaBrowser.Server.Implementations/WebSocket/AlchemyWebSocket.cs b/MediaBrowser.Server.Implementations/WebSocket/AlchemyWebSocket.csindex 13a9ce0505..7bf1fe86d0 100644--- a/MediaBrowser.Server.Implementations/WebSocket/AlchemyWebSocket.cs+++ b/MediaBrowser.Server.Implementations/WebSocket/AlchemyWebSocket.cs@@ -5,6 +5,7 @@ using System;using System.Text;using System.Threading;using System.Threading.Tasks;+using MediaBrowser.Model.Net;namespace MediaBrowser.Server.Implementations.WebSocket{diff --git a/MediaBrowser.WebDashboard/ApiClient.js b/MediaBrowser.WebDashboard/ApiClient.jsindex 94dc72d543..5381a7abd4 100644--- a/MediaBrowser.WebDashboard/ApiClient.js+++ b/MediaBrowser.WebDashboard/ApiClient.js@@ -1,54 +1,4 @@-(function (jQuery, window, undefined) {- "use strict";-- var matched, browser;-- jQuery.uaMatch = function (ua) {- ua = ua.toLowerCase();-- var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||- /(webkit)[ \/]([\w.]+)/.exec(ua) ||- /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||- /(msie) ([\w.]+)/.exec(ua) ||- ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||- [];-- var platform_match = /(ipad)/.exec(ua) ||- /(iphone)/.exec(ua) ||- /(android)/.exec(ua) ||- [];-- return {- browser: match[1] || "",- version: match[2] || "0",- platform: platform_match[0] || ""- };- };-- matched = jQuery.uaMatch(window.navigator.userAgent);- browser = {};-- if (matched.browser) {- browser[matched.browser] = true;- browser.version = matched.version;- }-- if (matched.platform) {- browser[matched.platform] = true- }-- // Chrome is Webkit, but Webkit is also Safari.- if (browser.chrome) {- browser.webkit = true;- } else if (browser.webkit) {- browser.safari = true;- }-- jQuery.browser = browser;--})(jQuery, window);--if (!window.MediaBrowser) {+if (!window.MediaBrowser) {window.MediaBrowser = {};}@@ -63,6 +13,16 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {*/return function (serverProtocol, serverHostName, serverPortNumber, clientName) {+ if (!serverProtocol) {+ throw new Error("Must supply a serverProtocol, e.g. http:");+ }+ if (!serverHostName) {+ throw new Error("Must supply serverHostName, e.g. 192.168.1.1 or myServerName");+ }+ if (!serverPortNumber) {+ throw new Error("Must supply a serverPortNumber");+ }+var self = this;var deviceName = "Web Browser";var deviceId = MediaBrowser.SHA1(navigator.userAgent + (navigator.cpuClass || ""));@@ -113,10 +73,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {else if ($.browser.msie) {name = "Internet Explorer";}- else if ($.browser.firefox) {- name = "Firefox";- }- else if ($.browser.mozilla) {+ else if ($.browser.firefox || $.browser.mozilla) {name = "Firefox";}else if ($.browser.opera) {@@ -147,15 +104,18 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {throw new Error("Request cannot be null");}- var auth = 'MediaBrowser Client="' + clientName + '", Device="' + deviceName + '", DeviceId="' + deviceId + '"';+ if (clientName) {- if (currentUserId) {- auth += ', UserId="' + currentUserId + '"';- }+ var auth = 'MediaBrowser Client="' + clientName + '", Device="' + deviceName + '", DeviceId="' + deviceId + '"';- request.headers = {- Authorization: auth- };+ if (currentUserId) {+ auth += ', UserId="' + currentUserId + '"';+ }++ request.headers = {+ Authorization: auth+ };+ }return $.ajax(request);};@@ -1933,4 +1893,54 @@ MediaBrowser.SHA1 = function (msg) {var temp = cvt_hex(H0) + cvt_hex(H1) + cvt_hex(H2) + cvt_hex(H3) + cvt_hex(H4);return temp.toLowerCase();-};\ No newline at end of file+};++(function (jQuery, window, undefined) {+ "use strict";++ var matched, browser;++ jQuery.uaMatch = function (ua) {+ ua = ua.toLowerCase();++ var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||+ /(webkit)[ \/]([\w.]+)/.exec(ua) ||+ /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||+ /(msie) ([\w.]+)/.exec(ua) ||+ ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||+ [];++ var platform_match = /(ipad)/.exec(ua) ||+ /(iphone)/.exec(ua) ||+ /(android)/.exec(ua) ||+ [];++ return {+ browser: match[1] || "",+ version: match[2] || "0",+ platform: platform_match[0] || ""+ };+ };++ matched = jQuery.uaMatch(window.navigator.userAgent);+ browser = {};++ if (matched.browser) {+ browser[matched.browser] = true;+ browser.version = matched.version;+ }++ if (matched.platform) {+ browser[matched.platform] = true+ }++ // Chrome is Webkit, but Webkit is also Safari.+ if (browser.chrome) {+ browser.webkit = true;+ } else if (browser.webkit) {+ browser.safari = true;+ }++ jQuery.browser = browser;++})(jQuery, window);\ No newline at end of filediff --git a/MediaBrowser.WebDashboard/packages.config b/MediaBrowser.WebDashboard/packages.configindex cd8da27323..5599c176d5 100644--- a/MediaBrowser.WebDashboard/packages.config+++ b/MediaBrowser.WebDashboard/packages.config@@ -1,6 +1,6 @@<?xml version="1.0" encoding="utf-8"?><packages>- <package id="MediaBrowser.ApiClient.Javascript" version="3.0.65" targetFramework="net45" />+ <package id="MediaBrowser.ApiClient.Javascript" version="3.0.67" targetFramework="net45" /><package id="ServiceStack.Common" version="3.9.42" targetFramework="net45" /><package id="ServiceStack.Text" version="3.9.42" targetFramework="net45" /></packages>\ No newline at end of file