lavva.exalushome
Version:
Library implementing communication and abstraction layers for ExalusHome system
93 lines (92 loc) • 4.15 kB
TypeScript
import * as signalR from "@microsoft/signalr";
import { IDataFrame } from "../DataFrame";
import { ConnectionResult, IExalusConnectionService, AuthorizationInfo, ConnectionState, StreamHandler, BrokerInfo } from "./IExalusConnectionService";
import { ITypedEvent } from "../TypedEvent";
export declare class SignalrLogger implements signalR.ILogger {
private readonly _log;
log(level: signalR.LogLevel, message: string): void;
}
export declare class ExalusConnectionService implements IExalusConnectionService {
private static readonly PING_INTERVAL_MS;
private static readonly MAX_CONSECUTIVE_PING_FAILURES;
private static readonly SERVER_TIMOUT_MS;
static SignalRLogLevel: signalR.LogLevel;
private _connection?;
private _connectTask;
private _authorizeTask;
private _pingTimerId;
private _consecutivePingFailures;
private _disconnectedOnPurpose;
private _address;
private _currentAddress?;
private _serversBrokerAddress;
private readonly _serversBrokerAddressList;
private _allBrokersChecked;
private readonly _packetsBrokerServers;
private _connectedServerAddressResult;
private readonly _connectedServerAddressWaiters;
private _isAuthorized;
private _serialId?;
private _PIN?;
private _lastReceivedPacket;
private _everConnected;
private readonly _pendingRequests;
private readonly _log;
private readonly _appState;
private _controllerConfiguration;
private _cache;
private _session;
private readonly _dataReceivedEvent;
private readonly _pongReceivedEvent;
private readonly _authorizationReceivedEvent;
private readonly _registrationReceivedEvent;
private readonly _streamStartedEvent;
private readonly _connectionStateChangedEvent;
private readonly _errorOccuredEvent;
static readonly ServiceName = "ExalusConnectionService";
constructor();
GetServiceName(): string;
GetAuthorizationInfo(): AuthorizationInfo | null;
GetControllerSerialNumber(): string | undefined;
GetControllerPin(): string | undefined;
SetServersBrokerAddress(a: string): void;
SetDefaultPacketsBrokerAddress(a: string): void;
GetConnectedBrokerInfoAsync(timeoutMs?: number | null): Promise<BrokerInfo>;
EnablePacketsLogging(): void;
DisablePacketsLogging(): void;
SubscribeTo<T>(resourceId: string, handler: (d: IDataFrame<T>) => void): () => void;
private reauthorizeIfPossible;
GetServerAddressAsync(): Promise<string | null>;
private rotateServersBroker;
ConnectAsync(address: string): Promise<ConnectionResult>;
ConnectAndAuthorizeAsync(info: AuthorizationInfo): Promise<ConnectionResult>;
private resetConnectedServerAddressResolution;
private resolveConnectedBrokerInfo;
AuthorizeAsync(info: AuthorizationInfo): Promise<boolean>;
IsConnected(): boolean;
DisconnectAsync(): Promise<void>;
SendAsync(dataFrame: IDataFrame<any>, logTx?: boolean): Promise<boolean>;
RestoreConnectionAsync(): Promise<boolean>;
SendAndWaitForResponseAsync<T>(dataFrame: IDataFrame<any>, timeout: number, useCache: boolean, logTransmission?: boolean, retryOnUnauthorized?: boolean): Promise<IDataFrame<T>>;
SendAndHandleResponseAsync<T>(dataFrame: IDataFrame<any>, timeout: number, dataHandler: (r: IDataFrame<T>) => void, logTransmission?: boolean): Promise<void>;
SendAndHandleStreamAsync<T>(dataFrame: IDataFrame<any>, streamHandler: StreamHandler<T>, logTransmission?: boolean): Promise<void>;
PingControllerAsync(): Promise<boolean>;
OnDataReceivedEvent(): ITypedEvent<any>;
OnConnectionStateChangedEvent(): ITypedEvent<ConnectionState>;
OnErrorOccuredEvent(): ITypedEvent<[string, string]>;
private serialisedConnect;
private waitForState;
private connectCore;
private waitForReconnection;
private initializeServices;
private wireConnectionEvents;
private startPingLoop;
private isBusy;
private pingOnce;
private validateConnectionToController;
private _tryReconnect;
private _onVisibility;
private _onHidden;
private _onVisible;
private cleanup;
}