import { ProviderInterface, ProviderInterface$Callback, ProviderInterface$Emitted, ProviderInterface$EmitCb } from '../types';
import './polyfill';
import E3 from 'eventemitter3';
declare type SubscriptionHandler = {
    callback: ProviderInterface$Callback;
    type: string;
};
interface WSProviderInterface extends ProviderInterface {
    connect(): void;
}
/**
 * @name WsProvider
 * @summary The WebSocket Provider allows sending requests using WebSocket to a WebSocket RPC server TCP port.
 * @description Unlike the [[HttpProvider]], it does support subscriptions and allows
 * listening to events such as new blocks or balance changes.
 * @example
 * <BR>
 *
 * ```javascript
 * import Api from '@polkadot/api';
 * import WsProvider from '@polkadot/api-provider/ws';
 *
 * const provider = new WsProvider('ws://127.0.0.1:9944');
 * const api = new Api(provider);
 * ```
 *
 * @see [[HttpProvider]]
 */
export default class WsProvider extends E3.EventEmitter implements WSProviderInterface {
    private autoConnect;
    private coder;
    private endpoint;
    private handlers;
    private _isConnected;
    private l;
    private queued;
    private subscriptions;
    private websocket;
    /**
     * @param {string}  endpoint    The endpoint url. Usually `ws://ip:9944` or `wss://ip:9944`
     * @param {boolean} autoConnect Whether to connect automatically or not.
     */
    constructor(endpoint: string, autoConnect?: boolean);
    /**
     * @summary Manually connect
     * @description The [[WsProvider]] connects automatically by default, however if you decided otherwise, you may
     * connect manually using this method.
     */
    connect(): void;
    /**
     * @summary Whether the node is connected or not.
     * @return {boolean} true if connected
     */
    isConnected(): boolean;
    /**
     * @summary Listens on events after having subscribed using the [[subscribe]] function.
     * @param  {ProviderInterface$Emitted} type Event
     * @param  {ProviderInterface$EmitCb}  sub  Callback
     * @return {this}                           [description]
     */
    on(type: ProviderInterface$Emitted, sub: ProviderInterface$EmitCb): this;
    /**
     * @summary Send JSON data using WebSockets to configured HTTP Endpoint or queue.
     */
    send(method: string, params: Array<any>, subscription?: SubscriptionHandler): Promise<any>;
    /**
     * @name subscribe
     * @summary Allows subscribing to a specific event.
     * @param  {string}                     type     Subscription type
     * @param  {string}                     method   Subscription method
     * @param  {Array<any>}                 params   Parameters
     * @param  {ProviderInterface$Callback} callback Callback
     * @return {Promise<number>}                     Promise resolving to the dd of the subscription you can use with [[unsubscribe]].
     *
     * @example
     * <BR>
     *
     * ```javascript
     * const provider = new WsProvider('ws://127.0.0.1:9944');
     * const api = new Api(provider);
     *
     * api.state.storage([[storage.balances.freeBalance, <Address>]], (_, values) => {
     *   console.log(values)
     * }).then((subscriptionId) => {
     *   console.log('balance changes subscription id: ', subscriptionId)
     * })
     * ```
     */
    subscribe(type: string, method: string, params: Array<any>, callback: ProviderInterface$Callback): Promise<number>;
    /**
     * @summary Allows unsubscribing to subscriptions made with [[subscribe]].
     */
    unsubscribe(type: string, method: string, id: number): Promise<boolean>;
    private onSocketClose;
    private onSocketError;
    private onSocketMessage;
    private onSocketMessageResult;
    private onSocketMessageSubscribe;
    private onSocketOpen;
}
export {};
