import { TransportType, TransportStatus, PeerInfo, StorageKey, ConnectionContext } from '@tezos-x/octez.connect-types'; import { PeerManager } from '../managers/PeerManager'; import { CommunicationClient } from './clients/CommunicationClient'; import { ClientEvents } from './clients/ClientEvents'; /** * @internalapi * * */ export declare abstract class Transport { /** * The type of the transport */ readonly type: TransportType; /** * The name of the app */ readonly name: string; /** * The status of the transport */ protected _isConnected: TransportStatus; protected readonly peerManager: PeerManager; /** * The client handling the encryption/decryption of messages */ protected client: S; /** * The listener that will be invoked when a new peer is connected */ protected newPeerListener?: (peer: T) => void; setEventHandler(event: ClientEvents, fun: Function): void; /** * The listeners that will be notified when new messages are coming in */ private listeners; /** * Return the status of the connection */ get connectionStatus(): TransportStatus; constructor(name: string, client: S, peerManager: PeerManager); /** * Returns a promise that resolves to true if the transport is available, false if it is not */ static isAvailable(): Promise; /** * Connect the transport */ connect(): Promise; /** * Disconnect the transport */ disconnect(): Promise; /** * Send a message through the transport * * @param message The message to send * @param recipient The recipient of the message */ send(message: string, peer?: PeerInfo): Promise; /** * Add a listener to be called when a new message is received * * @param listener The listener that will be registered */ addListener(listener: (message: unknown, connectionInfo: ConnectionContext) => void): Promise; /** * Remove a listener * * @param listener */ removeListener(listener: (message: string, connectionInfo: ConnectionContext) => void): Promise; getPeers(): Promise; addPeer(newPeer: T, _sendPairingResponse?: boolean): Promise; removePeer(peerToBeRemoved: T): Promise; removeAllPeers(): Promise; /** * Notify the listeners when a new message comes in * * @param message Message * @param connectionInfo Context info about the connection */ protected notifyListeners(message: unknown, connectionInfo: ConnectionContext): Promise; abstract listen(publicKey: string): Promise; }