show error dialog when failed to init websocket
This commit is contained in:
parent
0bf8c725a4
commit
ccac9d82a2
|
@ -199,6 +199,7 @@ RPC host cannot be empty!=RPC 主机不能为空!
|
||||||
RPC secret is not base64 encoded!=RPC 密钥不是 Base64 编码后的字符串!
|
RPC secret is not base64 encoded!=RPC 密钥不是 Base64 编码后的字符串!
|
||||||
URL is not base64 encoded!=指定 URL 不是 Base64 编码后的字符串!
|
URL is not base64 encoded!=指定 URL 不是 Base64 编码后的字符串!
|
||||||
Tap to configure and get started with AriaNg.=您还没有进行过设置, 点击这里进行设置.
|
Tap to configure and get started with AriaNg.=您还没有进行过设置, 点击这里进行设置.
|
||||||
|
Cannot initialize WebSocket!=无法初始化 WebSocket!
|
||||||
|
|
||||||
[error]
|
[error]
|
||||||
unknown=未知错误.
|
unknown=未知错误.
|
||||||
|
|
|
@ -199,6 +199,7 @@ RPC host cannot be empty!=RPC 主機不能為空!
|
||||||
RPC secret is not base64 encoded!=RPC 密鑰不是 Base64 編碼後的字元串!
|
RPC secret is not base64 encoded!=RPC 密鑰不是 Base64 編碼後的字元串!
|
||||||
URL is not base64 encoded!=指定 URL 不是 Base64 編碼後的字元串!
|
URL is not base64 encoded!=指定 URL 不是 Base64 編碼後的字元串!
|
||||||
Tap to configure and get started with AriaNg.=您還沒有進行過設置, 點擊這裡進行設置.
|
Tap to configure and get started with AriaNg.=您還沒有進行過設置, 點擊這裡進行設置.
|
||||||
|
Cannot initialize WebSocket!=無法初始化 WebSocket!
|
||||||
|
|
||||||
[error]
|
[error]
|
||||||
unknown=未知錯誤.
|
unknown=未知錯誤.
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
(function () {
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('ariaNg').config(['$translateProvider', 'localStorageServiceProvider', 'NotificationProvider', 'ariaNgConstants', 'ariaNgLanguages', function ($translateProvider, localStorageServiceProvider, NotificationProvider, ariaNgConstants, ariaNgLanguages) {
|
angular.module('ariaNg').config(['$qProvider', '$translateProvider', 'localStorageServiceProvider', 'NotificationProvider', 'ariaNgConstants', 'ariaNgLanguages', function ($qProvider, $translateProvider, localStorageServiceProvider, NotificationProvider, ariaNgConstants, ariaNgLanguages) {
|
||||||
|
$qProvider.errorOnUnhandledRejections(false);
|
||||||
|
|
||||||
localStorageServiceProvider
|
localStorageServiceProvider
|
||||||
.setPrefix(ariaNgConstants.appPrefix)
|
.setPrefix(ariaNgConstants.appPrefix)
|
||||||
.setStorageType('localStorage')
|
.setStorageType('localStorage')
|
||||||
|
|
|
@ -203,6 +203,7 @@
|
||||||
'RPC secret is not base64 encoded!': 'RPC secret is not base64 encoded!',
|
'RPC secret is not base64 encoded!': 'RPC secret is not base64 encoded!',
|
||||||
'URL is not base64 encoded!': 'URL is not base64 encoded!',
|
'URL is not base64 encoded!': 'URL is not base64 encoded!',
|
||||||
'Tap to configure and get started with AriaNg.': 'Tap to configure and get started with AriaNg.',
|
'Tap to configure and get started with AriaNg.': 'Tap to configure and get started with AriaNg.',
|
||||||
|
'Cannot initialize WebSocket!': 'Cannot initialize WebSocket!',
|
||||||
'error': {
|
'error': {
|
||||||
'unknown': 'Unknown error occurred.',
|
'unknown': 'Unknown error occurred.',
|
||||||
'operation.timeout': 'Operation timed out.',
|
'operation.timeout': 'Operation timed out.',
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
if (content.result && context.successCallback) {
|
if (content.result && context.successCallback) {
|
||||||
ariaNgLogService.debug('[aria2WebSocketRpcService.request] response uccess', content);
|
ariaNgLogService.debug('[aria2WebSocketRpcService.request] response success', content);
|
||||||
|
|
||||||
context.successCallback(context.id, content.result);
|
context.successCallback(context.id, content.result);
|
||||||
}
|
}
|
||||||
|
@ -65,28 +65,39 @@
|
||||||
|
|
||||||
var getSocketClient = function () {
|
var getSocketClient = function () {
|
||||||
if (socketClient === null) {
|
if (socketClient === null) {
|
||||||
socketClient = $websocket(rpcUrl);
|
try {
|
||||||
|
socketClient = $websocket(rpcUrl);
|
||||||
|
|
||||||
socketClient.onMessage(function (message) {
|
socketClient.onMessage(function (message) {
|
||||||
if (!message || !message.data) {
|
if (!message || !message.data) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var content = angular.fromJson(message.data);
|
||||||
|
|
||||||
|
if (!content) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (content.id) {
|
||||||
|
processMethodCallback(content);
|
||||||
|
} else if (content.method) {
|
||||||
|
processEventCallback(content);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (ex) {
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: 'Cannot initialize WebSocket!',
|
||||||
|
exception: ex
|
||||||
}
|
}
|
||||||
|
}
|
||||||
var content = angular.fromJson(message.data);
|
|
||||||
|
|
||||||
if (!content) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (content.id) {
|
|
||||||
processMethodCallback(content);
|
|
||||||
} else if (content.method) {
|
|
||||||
processEventCallback(content);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return socketClient;
|
return {
|
||||||
|
success: true,
|
||||||
|
instance: socketClient
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -108,7 +119,17 @@
|
||||||
deferred: deferred
|
deferred: deferred
|
||||||
};
|
};
|
||||||
|
|
||||||
client.send(requestBody);
|
if (client.instance) {
|
||||||
|
client.instance.send(requestBody);
|
||||||
|
} else {
|
||||||
|
deferred.reject({
|
||||||
|
success: false,
|
||||||
|
context: context
|
||||||
|
});
|
||||||
|
|
||||||
|
ariaNgLogService.debug('[aria2WebSocketRpcService.request] client error', client);
|
||||||
|
context.errorCallback(context.id, { message: client.error });
|
||||||
|
}
|
||||||
|
|
||||||
return deferred.promise;
|
return deferred.promise;
|
||||||
},
|
},
|
||||||
|
|
Reference in a new issue