|
|
|
@ -61,11 +61,14 @@ export class DecisionApi implements Api {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
getConnectionStatus(name: string): Promise<SocketResult> { |
|
|
|
|
return this.sendEditStatusEvent(name, editStatusEvent.OPEN) |
|
|
|
|
.then(re => { |
|
|
|
|
if (re.errorCode) { |
|
|
|
|
// TODO: 当前emit同步回调已无法执行
|
|
|
|
|
this.sendEditStatusEvent(name, editStatusEvent.OPEN); |
|
|
|
|
|
|
|
|
|
return new Promise((resolve, rejected) => { |
|
|
|
|
this.addEventListener(editStatusEvent.OPEN, res => { |
|
|
|
|
if (res.errorCode) { |
|
|
|
|
let errorMessage = ''; |
|
|
|
|
switch (re.errorCode) { |
|
|
|
|
switch (res.errorCode) { |
|
|
|
|
case errorCode.CONNECTION_DELETED: |
|
|
|
|
errorMessage = 'Dec-Dcm_Connection_Deleted'; |
|
|
|
|
break; |
|
|
|
@ -73,17 +76,18 @@ export class DecisionApi implements Api {
|
|
|
|
|
errorMessage = 'Dec-Dcm_Connection_Is_Using'; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
errorMessage = re.errorMsg; |
|
|
|
|
errorMessage = res.errorMsg; |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
BI.Msg.toast(BI.i18nText(errorMessage, re.errorMsg), { |
|
|
|
|
BI.Msg.toast(BI.i18nText(errorMessage, res.errorMsg), { |
|
|
|
|
level: 'error', |
|
|
|
|
}); |
|
|
|
|
throw re; |
|
|
|
|
rejected(res); |
|
|
|
|
} else { |
|
|
|
|
return re; |
|
|
|
|
resolve(res); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setEditedConnectionStatus(name: string): Promise<SocketResult> { |
|
|
|
@ -131,4 +135,14 @@ export class DecisionApi implements Api {
|
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private addEventListener(name: string, callback: Function) { |
|
|
|
|
if (!Dec.socket) return; |
|
|
|
|
|
|
|
|
|
if (Dec.socket.hasListeners(name)) { |
|
|
|
|
Dec.socket.removeListener(name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Dec.socket.originOn(name, callback); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|