///
import handler = require('../handler/queue');
import net = require('./net.types');
export declare enum SocketCloseKind {
WE_CLOSED_IT = 0,
REMOTELY_CLOSED = 1,
NEVER_CONNECTED = 2,
UNKOWN = 3,
}
export interface ConnectionInfo {
bound?: net.Endpoint;
remote?: net.Endpoint;
}
export declare function endpointOfSocketInfo(info: freedom.TcpSocket.SocketInfo): ConnectionInfo;
export declare class Server {
private endpoint_;
private maxConnections_;
private static numCreations_;
private id_;
private socket_;
private counter_;
private connections_;
connectionsQueue: handler.Queue;
private fulfillListening_;
private rejectListening_;
private onceListening_;
private fulfillShutdown_;
private onceShutdown_;
constructor(endpoint_: net.Endpoint, maxConnections_?: number);
private onDisconnectHandler_;
listen: () => Promise;
private onConnectionHandler_;
shutdown: () => Promise;
stopListening: () => Promise;
closeAll: () => Promise;
connections: () => Connection[];
connectionsCount: () => number;
onceListening: () => Promise;
onceShutdown: () => Promise;
toString: () => string;
}
export declare class Connection {
private startPaused_;
private static globalConnectionId_;
onceConnected: Promise;
onceClosed: Promise;
dataFromSocketQueue: handler.Queue;
dataToSocketQueue: handler.Queue;
connectionId: string;
private state_;
private connectionSocket_;
private counter_;
private fulfillClosed_;
constructor(connectionKind: Connection.Kind, startPaused_?: boolean);
private onData_;
receiveNext: () => Promise;
private onDisconnectHandler_;
pause: () => void;
resume: () => void;
close: () => Promise;
isClosed: () => boolean;
getState: () => Connection.State;
/**
* Sends a message that is pre-formatted as an arrayBuffer.
*/
send: (msg: ArrayBuffer) => Promise;
toString: () => string;
}
export declare module Connection {
interface Kind {
existingSocketId?: number;
endpoint?: net.Endpoint;
}
enum State {
ERROR = 0,
CONNECTING = 1,
CONNECTED = 2,
CLOSING = 3,
CLOSED = 4,
}
}