///
import express from 'express';
import { Server as HttpServer } from 'http';
import WebSocket from 'ws';
import { Handle } from '@theintern/common';
import Node from './executors/Node';
import { Message } from './channels/Base';
export interface Context {
readonly stopped: boolean;
readonly basePath: string;
readonly executor: Node;
handleMessage(message: Message): Promise;
}
export default class Server implements ServerProperties {
readonly executor: Node;
basePath: string;
port: number;
runInSync: boolean;
socketPort: number;
get stopped(): boolean;
protected _app: express.Express | undefined;
protected _httpServer: HttpServer | undefined;
protected _sessions: {
[id: string]: {
listeners: ServerListener[];
};
} | undefined;
protected _wsServer: WebSocket.Server | undefined;
protected _wsPingTimers: NodeJS.Timer[];
constructor(options: ServerOptions);
start(): Promise;
stop(): Promise;
subscribe(sessionId: string, listener: ServerListener): Handle;
private _getSession;
private _handleMessage;
private _handleWebSocket;
private _publish;
}
export interface ServerProperties {
basePath: string;
executor: Node;
port: number;
runInSync: boolean;
socketPort: number;
}
export interface ServerListener {
(name: string, data?: any): void;
}
export declare type ServerOptions = Partial & {
executor: Node;
};