diff --git a/server/src/io.ts b/server/src/io.ts new file mode 100644 index 000000000..4d5dfd74b --- /dev/null +++ b/server/src/io.ts @@ -0,0 +1,23 @@ +import { Server, Socket } from "engine.io"; + +export type IOServer = { + on(ev: 'connection' | 'drain', fn: (socket: IOSocket & T) => void): IOServer; +} & Server; + +export type IOSocket = { + send(data: any, options?: any, callback?: any): IOSocket; + + on(ev: "close", fn: (reason: string, description?: Error) => void): IOSocket; + /** + * Fired when the client sends a message. + */ + on(ev: "message", fn: (data: string | Buffer) => void): IOSocket; + /** + * Fired when an error occurs. + */ + on(ev: "error", fn: (err: Error) => void): IOSocket; + /** + * Called when the write buffer is drained + */ + on(ev: "drain", fn: () => void): IOSocket; +};