26 lines
554 B
TypeScript
26 lines
554 B
TypeScript
import {Session} from "express-session";
|
|
import {IncomingMessage} from "http";
|
|
import WebSocket from "ws";
|
|
|
|
import Application from "./Application.js";
|
|
|
|
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 handle(
|
|
socket: WebSocket,
|
|
request: IncomingMessage,
|
|
session: Session | null,
|
|
): Promise<void>;
|
|
}
|