mirror of
https://github.com/esiur/esiur-js.git
synced 2026-04-03 21:48:21 +00:00
Reconnect
This commit is contained in:
@@ -27,6 +27,8 @@
|
||||
"use strict";
|
||||
|
||||
import AsyncException from './AsyncException.js';
|
||||
import ExceptionCode from './ExceptionCode.js';
|
||||
import ErrorType from './ErrorType.js';
|
||||
|
||||
export default class AsyncReply extends Promise
|
||||
{
|
||||
@@ -88,16 +90,24 @@ export default class AsyncReply extends Promise
|
||||
timeout(milliseconds, onTimeout){
|
||||
let self = this;
|
||||
setTimeout(() => {
|
||||
if (!self.ready && self.exception == null)
|
||||
onTimeout();
|
||||
if (!self.ready && self.exception == null){
|
||||
|
||||
self.triggerError(ErrorType.Management, ExceptionCode.Timeout, "Execution timeout expired.");
|
||||
|
||||
if (onTimeout instanceof Function)
|
||||
onTimeout();
|
||||
}
|
||||
}, milliseconds);
|
||||
}
|
||||
|
||||
trigger(result)
|
||||
{
|
||||
if (this.ready)
|
||||
return;
|
||||
return this;
|
||||
|
||||
if (this.exception != null)
|
||||
return this;
|
||||
|
||||
this.result = result;
|
||||
this.ready = true;
|
||||
|
||||
|
||||
@@ -34,5 +34,7 @@ export default //const ExceptionCode =
|
||||
NotAttached: 31,
|
||||
AlreadyListened: 32,
|
||||
AlreadyUnlistened: 33,
|
||||
NotListenable: 34
|
||||
NotListenable: 34,
|
||||
ParseError: 35,
|
||||
Timeout: 36
|
||||
};
|
||||
Reference in New Issue
Block a user