improve web socket close
This commit is contained in:
parent
a0fea896fd
commit
b1b3a280a4
|
@ -27,14 +27,6 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
var currentUserId;
|
||||
var webSocket;
|
||||
|
||||
$(window).on("beforeunload", function () {
|
||||
|
||||
// Close the connection gracefully when possible
|
||||
if (webSocket && webSocket.readyState === WebSocket.OPEN) {
|
||||
webSocket.close();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Gets the server host name.
|
||||
*/
|
||||
|
@ -195,6 +187,12 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
};
|
||||
};
|
||||
|
||||
self.closeWebSocket = function () {
|
||||
if (webSocket && webSocket.readyState === WebSocket.OPEN) {
|
||||
webSocket.close();
|
||||
}
|
||||
};
|
||||
|
||||
self.sendWebSocketMessage = function (name, data) {
|
||||
|
||||
var msg = { MessageType: name };
|
||||
|
@ -3427,17 +3425,15 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi
|
|||
throw new Error("null itemId");
|
||||
}
|
||||
|
||||
// Always use the http api in case playback is stopped by closing the browser
|
||||
// See window beforeunload event at the top of this file
|
||||
//if (self.isWebSocketOpen()) {
|
||||
if (self.isWebSocketOpen()) {
|
||||
|
||||
// var deferred = $.Deferred();
|
||||
var deferred = $.Deferred();
|
||||
|
||||
// self.sendWebSocketMessage("PlaybackStopped", itemId + "|" + (positionTicks == null ? "" : positionTicks));
|
||||
self.sendWebSocketMessage("PlaybackStopped", itemId + "|" + (positionTicks == null ? "" : positionTicks));
|
||||
|
||||
// deferred.resolveWith(null, []);
|
||||
// return deferred.promise();
|
||||
//}
|
||||
deferred.resolveWith(null, []);
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
var params = {
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.172" targetFramework="net45" />
|
||||
<package id="MediaBrowser.ApiClient.Javascript" version="3.0.174" targetFramework="net45" />
|
||||
<package id="ServiceStack.Common" version="3.9.58" targetFramework="net45" />
|
||||
<package id="ServiceStack.Text" version="3.9.58" targetFramework="net45" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user