///
import { ServerConnection } from '@difizen/libro-kernel';
import type { Disposable, Disposed, Event } from '@difizen/mana-app';
import { Emitter } from '@difizen/mana-app';
import { TerminalOption } from './protocol.js';
import type { TerminalMessage, TerminalModel, TerminalConnectionStatus } from './protocol.js';
import { TerminalRestAPI } from './restapi.js';
export declare class TerminalConnection implements Disposable, Disposed {
protected _onDisposed: Emitter;
protected _messageReceived: Emitter;
protected _connectionStatus: TerminalConnectionStatus;
protected _connectionStatusChanged: Emitter;
protected _name: string;
protected _reconnectTimeout?: NodeJS.Timeout;
protected _ws?: WebSocket;
protected _noOp: () => void;
protected _reconnectLimit: number;
protected _reconnectAttempt: number;
protected _pendingMessages: TerminalMessage[];
terminalRestAPI: TerminalRestAPI;
serverConnection: ServerConnection;
disposed: boolean;
/**
* Construct a new terminal session.
*/
constructor(options: TerminalOption & {
name: string;
}, serverConnection: ServerConnection);
/**
* A signal emitted when a message is received from the server.
*/
get messageReceived(): Event;
get onDisposed(): Event;
/**
* Get the name of the terminal session.
*/
get name(): string;
/**
* Get the model for the terminal session.
*/
get model(): TerminalModel;
/**
* The server settings for the session.
*/
get serverSettings(): import("@difizen/libro-kernel").ISettings;
/**
* Dispose of the resources held by the session.
*/
dispose(): void;
/**
* Send a message to the terminal session.
*
* #### Notes
* If the connection is down, the message will be queued for sending when
* the connection comes back up.
*/
send(message: TerminalMessage): void;
/**
* Send a message on the websocket, or possibly queue for later sending.
*
* @param queue - whether to queue the message if it cannot be sent
*/
_sendMessage(message: TerminalMessage, queue?: boolean): void;
/**
* Send pending messages to the kernel.
*/
protected _sendPending(): void;
toDisposeOnReconnect: Disposable | undefined;
/**
* Reconnect to a terminal.
*/
reconnect: () => Promise;
/**
* Attempt a connection if we have not exhausted connection attempts.
*/
_reconnect(): void;
/**
* Forcefully clear the socket state.
*
* #### Notes
* This will clear all socket state without calling any handlers and will
* not update the connection status. If you call this method, you are
* responsible for updating the connection status as needed and recreating
* the socket if you plan to reconnect.
*/
protected _clearSocket(): void;
/**
* Shut down the terminal session.
*/
shutdown(): Promise;
/**
* Create the terminal websocket connection and add socket status handlers.
*
* #### Notes
* You are responsible for updating the connection status as appropriate.
*/
protected _createSocket: () => void;
protected _onWSMessage: (event: MessageEvent) => void;
protected _onWSClose: (event: CloseEvent) => void;
/**
* Handle connection status changes.
*/
protected _updateConnectionStatus(connectionStatus: TerminalConnectionStatus): void;
protected _errorIfDisposed(): void;
get connectionStatusChanged(): Event;
get connectionStatus(): TerminalConnectionStatus;
}
export declare function getRandomIntInclusive(min: number, max: number): number;
//# sourceMappingURL=connection.d.ts.map