/// import { Readable, Writable } from "stream"; import Event, { AutosaveOffEvent, AutosaveOnEvent, GameSaveEvent, CommunicatorEvent, PlayerQuitEvent } from "../Event"; import Player from "../Player"; import { StandardEmitter } from "./StandardEmitter"; declare type CommunicatorEventListener = (event: T) => void; /** * Player name alias for readability */ declare type PlayerName = string; /** * Should be created before the server has started. */ export default class ServerCommunicator { private listeners; protected _stdout: Readable | null; protected _stderr: Readable | null; protected _stdin: Writable | null; /** * @description contains all the standard streams */ std: StandardEmitter; events: CommunicatorEventEmitter; protected _players: Map; get players(): Readonly>; get playersArray(): Player[]; get playerCount(): number; protected _isServerJoinable: boolean; get isJoinable(): boolean; get hasStreams(): boolean; /** * @type {boolean} is true if the server is either starting or stopping */ get isUnstable(): boolean; constructor(stdin: Writable | null, stdout: Readable | null, stderr: Readable | null); /** * @description This should get called when the any of the server standard streams have been reassigned */ protected reload(): void; /** * @description Resets all values to default */ protected resetState(): void; private onError; private onMessage; private onLogin; private onLeave; private onReady; private notifyListeners; /** * * @param event The type of the event * @param listener The listener called everytime the event occurs */ on(event: T, listener: CommunicatorEventListener): void; /** * Only listens for the first instance of the event provided * @param event The event to listen for */ waitfor(event: T): Promise; /** * The event listener gets removed after the first occurrence of this event * @param event The type of the event * @param listener The listener called once the event occurs */ once(event: T, listener: CommunicatorEventListener): void; /** * * @param event The type of the event * @param listener The listener called everytime the event occurs * @throws {NoListenersError} if called when no listeners where created earlier */ removeListener(event: T, listener: ServerListener): void; /** * Deletes all resources created by this instance */ dispose(): void; } declare class CommunicatorEventEmitter { private communicator; constructor(communicator: ServerCommunicator); /** * Manually save the game */ saveGame(): Promise; disableAutosave(): Promise; enableAutosave(): Promise; kickPlayer(player: Player, message?: string): Promise; } declare class ServerListener { listener: CommunicatorEventListener; event: T; constructor(event: T, listener: CommunicatorEventListener); } export {}; //# sourceMappingURL=ServerCommunicator.d.ts.map