UNPKG

@ariva-mds/mds

Version:

Stock market data

32 lines (31 loc) 808 B
export 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(); } }