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 编码后的字符串!
|
||||
URL is not base64 encoded!=指定 URL 不是 Base64 编码后的字符串!
|
||||
Tap to configure and get started with AriaNg.=您还没有进行过设置, 点击这里进行设置.
|
||||
Cannot initialize WebSocket!=无法初始化 WebSocket!
|
||||
|
||||
[error]
|
||||
unknown=未知错误.
|
||||
|
|
|
@ -199,6 +199,7 @@ RPC host cannot be empty!=RPC 主機不能為空!
|
|||
RPC secret is not base64 encoded!=RPC 密鑰不是 Base64 編碼後的字元串!
|
||||
URL is not base64 encoded!=指定 URL 不是 Base64 編碼後的字元串!
|
||||
Tap to configure and get started with AriaNg.=您還沒有進行過設置, 點擊這裡進行設置.
|
||||
Cannot initialize WebSocket!=無法初始化 WebSocket!
|
||||
|
||||
[error]
|
||||
unknown=未知錯誤.
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
(function () {
|
||||
'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
|
||||
.setPrefix(ariaNgConstants.appPrefix)
|
||||
.setStorageType('localStorage')
|
||||
|
|
|
@ -203,6 +203,7 @@
|
|||
'RPC secret is not base64 encoded!': 'RPC secret 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.',
|
||||
'Cannot initialize WebSocket!': 'Cannot initialize WebSocket!',
|
||||
'error': {
|
||||
'unknown': 'Unknown error occurred.',
|
||||
'operation.timeout': 'Operation timed out.',
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
});
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -65,6 +65,7 @@
|
|||
|
||||
var getSocketClient = function () {
|
||||
if (socketClient === null) {
|
||||
try {
|
||||
socketClient = $websocket(rpcUrl);
|
||||
|
||||
socketClient.onMessage(function (message) {
|
||||
|
@ -84,9 +85,19 @@
|
|||
processEventCallback(content);
|
||||
}
|
||||
});
|
||||
} catch (ex) {
|
||||
return {
|
||||
success: false,
|
||||
error: 'Cannot initialize WebSocket!',
|
||||
exception: ex
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return socketClient;
|
||||
return {
|
||||
success: true,
|
||||
instance: socketClient
|
||||
};
|
||||
};
|
||||
|
||||
return {
|
||||
|
@ -108,7 +119,17 @@
|
|||
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;
|
||||
},
|
||||
|
|
Reference in a new issue