///
import * as schema from '@stencila/schema';
import net from 'net';
import { Connection } from '../base/Connection';
import { Executor } from '../base/Executor';
import { Server } from '../base/Server';
import { Addresses, HttpAddress, TcpAddress, TcpAddressInitializer, WebSocketAddress } from '../base/Transports';
import { StreamServer } from '../stream/StreamServer';
/**
* A TCP connection.
*
* Each connection acts as a `StreamServer`, sending and receving
* length-prexied messages over the TCP stream.
*/
export declare class TcpConnection extends StreamServer implements Connection {
/**
* @implements Implements {@link Connection.id} to provide
* a unique id for the TCP connection.
*/
id: string;
/**
* The socket used by this connection.
*/
socket: net.Socket;
/**
* The server for this connection.
*
* Used to implement {@link TcpConnection.addresses}.
*/
server: TcpServer;
constructor(socket: net.Socket, server: TcpServer);
/**
* @implements Implements {@link Server.addresses}. Necessary
* because that is an `abstract` method. Just returns addresses
* of the server that this connection is to.
*/
addresses(): Promise;
/**
* @implements Implements {@link Connection.stop} by `end`ing
* and `unref`ing the socket. According to the docs `destroy()`
* should be only be used if there are errors.
*/
stop(): Promise;
}
export declare class TcpServer extends Server {
/**
* The address of this server.
*
* Can be a `TcpAddress`, or one of the address types
* derived from it.
*/
readonly address: TcpAddress | HttpAddress | WebSocketAddress;
protected server?: net.Server;
protected connections: {
[key: string]: Connection;
};
constructor(address?: TcpAddressInitializer);
/**
* @implements Implements {@link Server.addresses}.
*/
addresses(): Promise;
/**
* Generate the IP address and port number that this server should
* use for listening.
*
* Translates `this.address`, which is an "advertised" address
* into a "listening" address. Assumes that this process is not
* running as a privileged user so overrides any use, implied or
* otherwise, of a privileged port.
*/
listeningAddress(): [string, number];
protected onConnected(connection: Connection): void;
protected onDisconnected(connection: Connection): void;
start(executor: Executor): Promise;
/**
* @override Override of {@link Server.notify} that notifies clients
* via this server's stored `Connection` instances. If the `clients`
* argument is not supplied then notifies all clients.
*/
notify(level: string, message: string, node?: schema.Node, clients?: string[]): void;
stop(): Promise;
}