auto reconnect when connect aria2 via websocket
This commit is contained in:
parent
b57381cb0c
commit
317348ebbd
|
@ -13,6 +13,7 @@
|
||||||
defaultHost: 'localhost',
|
defaultHost: 'localhost',
|
||||||
defaultSecureProtocol: 'https',
|
defaultSecureProtocol: 'https',
|
||||||
defaultPathSeparator: '/',
|
defaultPathSeparator: '/',
|
||||||
|
websocketAutoReconnect: true,
|
||||||
globalStatStorageCapacity: 120,
|
globalStatStorageCapacity: 120,
|
||||||
taskStatStorageCapacity: 300,
|
taskStatStorageCapacity: 300,
|
||||||
lazySaveTimeout: 500,
|
lazySaveTimeout: 500,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').factory('aria2WebSocketRpcService', ['$q', '$websocket', 'ariaNgSettingService', 'ariaNgLogService', function ($q, $websocket, ariaNgSettingService, ariaNgLogService) {
|
angular.module('ariaNg').factory('aria2WebSocketRpcService', ['$q', '$websocket', 'ariaNgConstants', 'ariaNgSettingService', 'ariaNgLogService', function ($q, $websocket, ariaNgConstants, ariaNgSettingService, ariaNgLogService) {
|
||||||
var rpcUrl = ariaNgSettingService.getCurrentRpcUrl();
|
var rpcUrl = ariaNgSettingService.getCurrentRpcUrl();
|
||||||
var socketClient = null;
|
var socketClient = null;
|
||||||
|
|
||||||
|
@ -72,7 +72,9 @@
|
||||||
var getSocketClient = function (context) {
|
var getSocketClient = function (context) {
|
||||||
if (socketClient === null) {
|
if (socketClient === null) {
|
||||||
try {
|
try {
|
||||||
socketClient = $websocket(rpcUrl);
|
socketClient = $websocket(rpcUrl, {
|
||||||
|
reconnectIfNotNormalClose: ariaNgConstants.websocketAutoReconnect
|
||||||
|
});
|
||||||
|
|
||||||
socketClient.onMessage(function (message) {
|
socketClient.onMessage(function (message) {
|
||||||
if (!message || !message.data) {
|
if (!message || !message.data) {
|
||||||
|
|
Reference in a new issue