export interface SendableConnection { send ( data ) : void ; } export interface ReadWriteConnection extends SendableConnection { /**
     * Message received from the connection.
     */ onMessage ( cb ) : void ; /**
     * Indicates permanent closure, meaning we should dispose.
     */ onClose ( cb ) : void ; /**
     * Connection is temporarily down.
     */ onDown ( cb ) : void ; /**
     * Connection is back up.
     */ onUp ( cb ) : void ; } export type LoggerArgument = ( ( ) => Array < { [ key ] : any ; } > ) | { [ key ] : any ; } ; export interface Logger { trace ( message , ... args ) : void ; error ( message , ... args ) : void ; } export class DefaultLogger implements Logger { public constructor ( private readonly name ) { } public trace ( message , ... args ) { if ( typeof process !== "undefined" && process . env && process . env . LOG_LEVEL === "trace" ) { this . log ( message , ... args ) ; } } public error ( message , ... args ) { this . log ( message , ... args ) ; } private log ( message , ... args ) { console . log ( `[${ this . name }]` , message , ... args . map ( ( a ) => JSON . stringify ( typeof a === "function" ? a ( ) : a ) ) ) ; } } export enum ConnectionStatus { Disconnected , Connected , Closed }