/**
* Connect an external client / transport through the MHub protocol to the
* internal Hub.
*/
///
import * as events from "events";
import Hub from "./hub";
import * as protocol from "./protocol";
/**
* Link of one client to the hub.
* Every transport (tcp, websocket, etc.) and the LocalClient use this to
* connect to the hub, passing it raw JSON objects received over the wire
* to `processCommand()` and receiving responses from it by listing to
* the `response` event.
*
* Events emitted from HubClient:
* @event response(data: protocol.Response) Emitted whenever a response to
* a command, or new data to a subscription, is sent to this client.
*/
export declare class HubClient extends events.EventEmitter {
name: string;
private _hub;
private _subscriptions;
private _username;
private _authorizer;
constructor(hub: Hub, name: string);
/**
* Disconnect from Hub.
*/
close(): void;
/**
* Set username.
* The MHub protocol provides a login command, which can be used
* to allow authentication across transports that otherwise don't
* natively support it (e.g. raw tcp).
* Some transports may deduce the authentication user using other
* means (e.g. in SSL client certificate).
*
* Note: using this will make a subsequent login command fail.
*
* @param username Username to assume.
*/
setUsername(username: string): void;
/**
* Validate and execute command against hub (e.g. login, publish,
* subscribe, etc.).
* Any response to the command (including errors) will be
* passed back using the `response` event.
*
* @param msg Command to process.
*/
processCommand(msg: protocol.Command): Promise;
private _handlePublish;
private _handleSubscribe;
private _handleUnsubscribe;
private _handlePing;
private _handleLogin;
private _onResponseHandler;
}
export default HubClient;