Moved some web socket classes to the model
This commit is contained in:
parent
3a5e1521ed
commit
a6c9fdd0f2
|
@ -87,8 +87,6 @@
|
||||||
<Compile Include="Net\MimeTypes.cs" />
|
<Compile Include="Net\MimeTypes.cs" />
|
||||||
<Compile Include="Net\UdpMessageReceivedEventArgs.cs" />
|
<Compile Include="Net\UdpMessageReceivedEventArgs.cs" />
|
||||||
<Compile Include="Net\WebSocketConnectEventArgs.cs" />
|
<Compile Include="Net\WebSocketConnectEventArgs.cs" />
|
||||||
<Compile Include="Net\WebSocketMessageType.cs" />
|
|
||||||
<Compile Include="Net\WebSocketState.cs" />
|
|
||||||
<Compile Include="Plugins\IPlugin.cs" />
|
<Compile Include="Plugins\IPlugin.cs" />
|
||||||
<Compile Include="Plugins\IUIPlugin.cs" />
|
<Compile Include="Plugins\IUIPlugin.cs" />
|
||||||
<Compile Include="Progress\ActionableProgress.cs" />
|
<Compile Include="Progress\ActionableProgress.cs" />
|
||||||
|
|
|
@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Net
|
namespace MediaBrowser.Common.Net
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Net
|
namespace MediaBrowser.Common.Net
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Net
|
namespace MediaBrowser.Common.Net
|
||||||
{
|
{
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
<Compile Include="Dto\ChapterInfoDto.cs" />
|
<Compile Include="Dto\ChapterInfoDto.cs" />
|
||||||
<Compile Include="Dto\IItemDto.cs" />
|
<Compile Include="Dto\IItemDto.cs" />
|
||||||
<Compile Include="Entities\IByReferenceItem.cs" />
|
<Compile Include="Entities\IByReferenceItem.cs" />
|
||||||
|
<Compile Include="Net\WebSocketMessageType.cs" />
|
||||||
|
<Compile Include="Net\WebSocketState.cs" />
|
||||||
<Compile Include="Querying\ItemsByNameQuery.cs" />
|
<Compile Include="Querying\ItemsByNameQuery.cs" />
|
||||||
<Compile Include="Entities\BaseItemInfo.cs" />
|
<Compile Include="Entities\BaseItemInfo.cs" />
|
||||||
<Compile Include="Connectivity\ClientConnectionInfo.cs" />
|
<Compile Include="Connectivity\ClientConnectionInfo.cs" />
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Net
|
namespace MediaBrowser.Model.Net
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enum WebSocketMessageType
|
/// Enum WebSocketMessageType
|
||||||
|
@ -17,6 +17,6 @@ namespace MediaBrowser.Common.Net
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The close
|
/// The close
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Close,
|
Close
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Net
|
namespace MediaBrowser.Model.Net
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Enum WebSocketState
|
/// Enum WebSocketState
|
|
@ -4,8 +4,8 @@ using System;
|
||||||
using System.Net.WebSockets;
|
using System.Net.WebSockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using WebSocketMessageType = MediaBrowser.Common.Net.WebSocketMessageType;
|
using WebSocketMessageType = MediaBrowser.Model.Net.WebSocketMessageType;
|
||||||
using WebSocketState = MediaBrowser.Common.Net.WebSocketState;
|
using WebSocketState = MediaBrowser.Model.Net.WebSocketState;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.HttpServer
|
namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
{
|
{
|
||||||
|
@ -83,7 +83,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||||
}
|
}
|
||||||
catch (WebSocketException ex)
|
catch (WebSocketException ex)
|
||||||
{
|
{
|
||||||
_logger.ErrorException("Error reveiving web socket message", ex);
|
_logger.ErrorException("Error receiving web socket message", ex);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
using MediaBrowser.Common.Net;
|
using MediaBrowser.Common.Net;
|
||||||
using MediaBrowser.Model.Logging;
|
using MediaBrowser.Model.Logging;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
using MediaBrowser.Model.Serialization;
|
using MediaBrowser.Model.Serialization;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Model.Net;
|
||||||
|
|
||||||
namespace MediaBrowser.Server.Implementations.WebSocket
|
namespace MediaBrowser.Server.Implementations.WebSocket
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,54 +1,4 @@
|
||||||
(function (jQuery, window, undefined) {
|
if (!window.MediaBrowser) {
|
||||||
"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) {
|
|
||||||
window.MediaBrowser = {};
|
window.MediaBrowser = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +13,16 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
||||||
*/
|
*/
|
||||||
return function (serverProtocol, serverHostName, serverPortNumber, clientName) {
|
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 self = this;
|
||||||
var deviceName = "Web Browser";
|
var deviceName = "Web Browser";
|
||||||
var deviceId = MediaBrowser.SHA1(navigator.userAgent + (navigator.cpuClass || ""));
|
var deviceId = MediaBrowser.SHA1(navigator.userAgent + (navigator.cpuClass || ""));
|
||||||
|
@ -113,10 +73,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
||||||
else if ($.browser.msie) {
|
else if ($.browser.msie) {
|
||||||
name = "Internet Explorer";
|
name = "Internet Explorer";
|
||||||
}
|
}
|
||||||
else if ($.browser.firefox) {
|
else if ($.browser.firefox || $.browser.mozilla) {
|
||||||
name = "Firefox";
|
|
||||||
}
|
|
||||||
else if ($.browser.mozilla) {
|
|
||||||
name = "Firefox";
|
name = "Firefox";
|
||||||
}
|
}
|
||||||
else if ($.browser.opera) {
|
else if ($.browser.opera) {
|
||||||
|
@ -147,16 +104,19 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) {
|
||||||
throw new Error("Request cannot be null");
|
throw new Error("Request cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
var auth = 'MediaBrowser Client="' + clientName + '", Device="' + deviceName + '", DeviceId="' + deviceId + '"';
|
if (clientName) {
|
||||||
|
|
||||||
if (currentUserId) {
|
var auth = 'MediaBrowser Client="' + clientName + '", Device="' + deviceName + '", DeviceId="' + deviceId + '"';
|
||||||
auth += ', UserId="' + currentUserId + '"';
|
|
||||||
|
if (currentUserId) {
|
||||||
|
auth += ', UserId="' + currentUserId + '"';
|
||||||
|
}
|
||||||
|
|
||||||
|
request.headers = {
|
||||||
|
Authorization: auth
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
request.headers = {
|
|
||||||
Authorization: auth
|
|
||||||
};
|
|
||||||
|
|
||||||
return $.ajax(request);
|
return $.ajax(request);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1934,3 +1894,53 @@ MediaBrowser.SHA1 = function (msg) {
|
||||||
|
|
||||||
return temp.toLowerCase();
|
return temp.toLowerCase();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
(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);
|
|
@ -1,6 +1,6 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<packages>
|
<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.Common" version="3.9.42" targetFramework="net45" />
|
||||||
<package id="ServiceStack.Text" version="3.9.42" targetFramework="net45" />
|
<package id="ServiceStack.Text" version="3.9.42" targetFramework="net45" />
|
||||||
</packages>
|
</packages>
|
Loading…
Reference in New Issue
Block a user