import { Subject } from 'rxjs'; import { IHubConnection } from '../communicator'; import { Sentinel } from './index'; export declare type TFeatureStatus = 'unknown' | 'unavailable' | 'connected' | 'disconnected' | 'reconnecting'; /** * The SignalR event format received from the sentinel for status updates * * @export * @interface IHubEventSentinelStatus */ export interface IHubEventSentinelStatus { Online: boolean; } /** * This the response format of the on-demand GetStatus message * * @export * @interface IGetStatus */ export interface IGetStatus { CloudOnline: boolean; InternetOnline: boolean; } /** * The payload for the status change event * * @export * @interface IStatusChange */ export interface IStatusChange { internet: TFeatureStatus; eva: TFeatureStatus; sentinel: TFeatureStatus; } /** * This class exposes the status features of the sentinel * These will listen to the sentinel to the sentinel signalR hub if available * * @export * @class SentinelStatus */ export declare class SentinelStatus { private parent; /** * The current status of the internet connection as reported by the sentinel * * @type {TFeatureStatus} */ internet: TFeatureStatus; /** * The current status of the EVA platform as reported by the sentinel * * @type {TFeatureStatus} */ eva: TFeatureStatus; /** * The current status of the sentinel itself * * @type {TFeatureStatus} */ sentinel: TFeatureStatus; /** * The status change stream * * @type {Subject} * @memberof SentinelStatus */ changes$: Subject; /** * The signalR hub connection to the sentinel * * @private * @type {IHubConnection?} */ hub: IHubConnection | undefined; /** * Reconnect counter to help maintain the SignalR connection * * @private */ private reconnectCount; /** * Creates an instance of SentinelStatus * * @param {Sentinel} parent The parent sentinel class */ constructor(parent: Sentinel); /** * Start listening for status updated from the sentinel SignalR hub * Note that this can be called multiple times in succession if new application * configuration responses arrive. * We need to remember which sentinel we are talking to and stay connected if * the url does not change * * @returns */ start(): Promise; /** * Stops all status checks * * @returns */ stop(): Promise; /** * On demand status update call * * @returns */ getStatus(): Promise; /** * Helper method to emit a status change * * @private */ private emitStatusChange; /** * Helper method to try to reconnect to the SignalR server * We will use the reconnect count and multiply it with a small interval * which will effectively increment it for each attempt * Max delay is set to 10 minutes * * @private * @param {IHubConnection} hubDetails */ private reconnectAttempt; }