2020-04-22 15:52:17 +02:00
|
|
|
import WebSocket from "ws";
|
|
|
|
import {IncomingMessage} from "http";
|
2020-07-19 11:57:47 +02:00
|
|
|
import Application from "./Application";
|
|
|
|
|
|
|
|
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-07-19 17:37:10 +02:00
|
|
|
public abstract async handle(socket: WebSocket, request: IncomingMessage, session: Express.SessionData | null): Promise<void>;
|
2020-04-22 15:52:17 +02:00
|
|
|
}
|