swaf/src/WebSocketListener.ts

26 lines
554 B
TypeScript
Raw Normal View History

import {Session} from "express-session";
import {IncomingMessage} from "http";
import WebSocket from "ws";
import Application from "./Application.js";
2020-07-19 11:57:47 +02:00
export default abstract class WebSocketListener<T extends Application> {
private app!: T;
public init(app: T): void {
this.app = app;
}
2020-04-22 15:52:17 +02:00
protected getApp(): T {
return this.app;
}
2020-04-22 15:52:17 +02:00
public abstract path(): string;
public abstract handle(
socket: WebSocket,
request: IncomingMessage,
session: Session | null,
): Promise<void>;
}