import EventEmitter from './EventEmitter'; import { IConfig } from './Utils'; export declare const CLIENT_CONFIG_DEFAULTS: { url: string; logging: boolean; hubClient: boolean; logger: null; totalTransportConnectTimeout: number; }; declare class DefaultDictionary { [propName: string]: any; } /** * The public API for managing communications with a SignalR server * @class * @public */ export default class Client extends EventEmitter { protected connectionData: Array; protected connectionId: string; protected _logger: any; protected _config: DefaultDictionary; private _transport; private _connectingMessageBuffer; private _state; /** * Initializes th' client object wit' userdefined options. Options can include a multitude 'o properties, includin' th' ship URL, * a set transport protocol th' user wishes to use, a hub client, th' timeout to use when connection, 'n loggin' mechanisms. * @param {Object} options Defines the options that the client will initialize with. * @constructs * @returns {Client} Returns a new client object. */ constructor(options: IConfig); /** * Accessor fer th' state property 'o th' client. Sets th' state to newState 'n automatically emits th' correct events. * @param {string} newState The new state of the client. * @public * @emits stateChanging * @emits stateChanged * @returns {void} Nothing is returned by this method. */ /** * Accessor fer th' state property 'o th' client. Returns th' current state 'o th' client. * @returns {*} Returns the current state. */ state: number; /** * Starts th' underlyin' connection to th' ship. * @param {Object} options contains any updated treaty values that be used to start th' connection. * @returns {Promise} that resolves once th' connection be opened successfully. * @public * @function * @emits starting * @emits started * @emits error */ start(options?: any): any; /** * Stops th' connection to th' ship * @returns {Promise} that resolves once th' connection has closed successfully. * @public * @function * @emits stopping * @emits stopped */ stop(): void; /** * Sends a message to th' connected ship if th' transport be valid. * @param {object} data Th' message to send. * @public * @function * @returns {void} Nothing is returned by this method. */ send(data: any): void; /** * A connnection and client event handler that is listening for an 'error' event. * Event is emitted when an error is thrown. * @param {function} callback Contains the error message. //TODO: Implement error events * @function * @public * @returns {void} Nothing is returned by this method. */ error(callback: Function): void; /** * A client event handler that is listening for a 'starting' event. * Event is emitted when the client begins initialization. * @param {function} callback Method that is executed once a starting event has been fired. * @function * @public * @returns {void} Nothing is returned by this method. */ starting(callback: Function): void; /** * A client event handler that is listening for a 'started' event. * Event is emitted once the client has secured a connection successfully. * @param {function} callback Method that is executed once a starting event has been fired. * @function * @public * @returns {void} Nothing is returned by this method. */ started(callback: Function): void; /** * A client event handler that is listening for a 'stopping' event. * Event is emitted once the client has initiated a disconnect. * @param {function} callback Method that is executed once a starting event has been fired. * @function * @public * @returns {void} Nothing is returned by this method. */ stopping(callback: Function): void; /** * A client event handler that is listening for a 'stopped' event. * Event is emitted once the client has successfully disconnected from the server. * @param {function} callback Method that is executed once a starting event has been fired. * @function * @public * @returns {void} Nothing is returned by this method. */ stopped(callback: Function): void; /** * A connection and client event handler that is listening for a 'receiving' event. * Event is emitted whenever a message is received by the client from the server. (Message is in compressed, raw form from server). * @param {function} callback Contains the compressed message data that the client is currently receiving. * @function * @public * @returns {void} Nothing is returned by this method. */ receiving(callback: Function): void; /** * A connection and client event handler that is listening for a 'received' event. * Event is emitted whenever a message is received by the client from the server. (Message is decompressed by client, making it more managable). * @param {function} callback Contains the received decompressed message data. * @function * @public * @returns {void} Nothing is returned by this method. */ received(callback: Function): void; /** * A connection and client event handler that is listening for a 'stateChanging' event. * Event is emitted whenever the client's state or the connection's state is in the process of changing. * @param {function} callback Contains both the old and new state. * @function * @public * @returns {void} Nothing is returned by this method. */ stateChanging(callback: Function): void; /** * A connection and client event handler that is listening for a 'stateChanged' event. * Event is emitted whenever the client's state or the connection's state has changed. * @param {function} callback Contains the new state. * @function * @public * @returns {void} Nothing is returned by this method. */ stateChanged(callback: Function): void; /** * A connection event handler that is listening for a 'disconnecting' event. * Event is emitted once the connection is in the process of stopping, initiated by the user, or automatically if the connection is lost unexpectedly. * @param {function} callback Method that is executed once a starting event has been fired. * @function * @public * @returns {void} Nothing is returned by this method. */ disconnecting(callback: Function): void; /** * A connection event handler that is listening for a 'disconnected' event. * Event is emitted once the connection has been completely haulted by the uesr, or has been lost unexpectedly. * @param {function} callback Method that is executed once a starting event has been fired. * @function * @public * @returns {void} Nothing is returned by this method. */ disconnected(callback: Function): void; /** * A connection event handler that is listening for a 'reconnecting' event. * Event is emitted if the connection has been lost unexpectedly and is automatically attempting to reconnect. * @param {function} callback Method that is executed once a starting event has been fired. * @function * @public * @returns {void} Nothing is returned by this method. */ reconnecting(callback: Function): void; /** * A connection event handler that is listening for a 'reconnected' event. * Event is emitted if the connection has been successfully re-established after an unexpected disconnect. * @param {function} callback Method that is executed once a starting event has been fired. * @function * @public * @returns {void} Nothing is returned by this method. */ reconnected(callback: Function): void; /** * A connection event listener that is listening for a 'connecting' event. * Event is emitted if the user has used the client to try and negotiate a connection to a server. * @param {function} callback Method that is executed once a starting event has been fired. * @function * @public * @returns {void} Nothing is returned by this method. */ connecting(callback: Function): void; /** * A connection event listener that is listening for a 'onConnected' event. * Event is emitted if the connection to the server was successfully established. * @param {function} callback Method that is executed once a starting event has been fired. * @function * @public * @returns {void} Nothing is returned by this method. */ connected(callback: Function): void; /** * A connection event listener that is listeing for a 'connectionSlow' event. * Currently not implemented. * @param {function} callback Method that is executed once a starting event has been fired. * @function * @public * @returns {void} Nothing is returned by this method. */ connectionSlow(callback: Function): void; /** * Negotiates th' request to th' ship 'n returns th' consequental promise that be created as a result. * @returns {*} Returns the treaty for the server request. * @protected * @function */ private negotiate; /** * Takes a treaty (result 'o negotiate()) 'n uses that 'n th' client configuration to find th' best transport protocol to use. * A user may specify a transport as well if they would like to not use th' automated selection 'o one. * @param {Object} treaty The result of the initial negotiation with the server. * @returns {Promise} A promise that will automatically find the best connection type, or to use the one defined by the user. * @function * @private */ private findTransport; } export {}; //# sourceMappingURL=Client.d.ts.map