@ariva-mds/mds
Version:
Stock market data
37 lines (36 loc) • 1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MdsConnectionState = void 0;
class MdsConnectionState {
constructor(timeoutMs = 20000) {
this.isConnected = false;
this.isAuthenticated = false;
this.lastUpdate = new Date();
this.timeoutMs = timeoutMs;
}
connectionOpened() {
this.isConnected = true;
this.isAuthenticated = false;
this.lastUpdate = new Date();
}
connectionClosed() {
this.isConnected = false;
this.isAuthenticated = false;
}
authenticationAccepted() {
this.isAuthenticated = true;
}
authenticationEnded() {
this.isAuthenticated = false;
}
messageReceived() {
this.lastUpdate = new Date();
}
isTimedOut() {
return Date.now() - this.lastUpdate.getTime() >= this.timeoutMs;
}
forcedDisconnect() {
this.lastUpdate = new Date();
}
}
exports.MdsConnectionState = MdsConnectionState;