UNPKG

@ariva-mds/mds

Version:

Stock market data

36 lines (35 loc) 964 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MdsConnectionState = void 0; class MdsConnectionState { constructor() { this.isConnected = false; this.isAuthenticated = false; this.lastUpdate = new Date(); } 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() < 20000; // 20 seconds timeout } forcedDisconnect() { this.lastUpdate = new Date(); } } exports.MdsConnectionState = MdsConnectionState;