2020-12-04 14:42:09 +01:00
|
|
|
import {Session} from "express-session";
|
2021-05-03 19:29:22 +02:00
|
|
|
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
|
|
|
|
2020-07-19 12:21:56 +02:00
|
|
|
protected getApp(): T {
|
|
|
|
return this.app;
|
|
|
|
}
|
|
|
|
|
2020-04-22 15:52:17 +02:00
|
|
|
public abstract path(): string;
|
|
|
|
|
2020-12-04 14:42:09 +01:00
|
|
|
public abstract handle(
|
2020-09-25 23:42:15 +02:00
|
|
|
socket: WebSocket,
|
|
|
|
request: IncomingMessage,
|
2020-12-04 14:42:09 +01:00
|
|
|
session: Session | null,
|
2020-09-25 23:42:15 +02:00
|
|
|
): Promise<void>;
|
|
|
|
}
|