swaf/src/WebSocketListener.ts

19 lines
495 B
TypeScript

import WebSocket from "ws";
import {IncomingMessage} from "http";
import Application from "./Application";
export default abstract class WebSocketListener<T extends Application> {
private app!: T;
public init(app: T): void {
this.app = app;
}
protected getApp(): T {
return this.app;
}
public abstract path(): string;
public abstract async handle(socket: WebSocket, request: IncomingMessage, session: Express.SessionData | null): Promise<void>;
}