Pass a whole Session to WebSocketListeners

This commit is contained in:
Alice Gaudon 2020-09-23 08:55:35 +02:00
parent 6305a69583
commit 79d3b51f90
4 changed files with 4 additions and 4 deletions

View File

@ -1,6 +1,6 @@
{
"name": "wms-core",
"version": "0.22.0-rc.15",
"version": "0.22.0-rc.16",
"description": "Node web application framework and toolbelt.",
"repository": "https://gitlab.com/ArisuOngaku/wms-core",
"author": "Alice Gaudon <alice@gaudon.pro>",

View File

@ -15,5 +15,5 @@ export default abstract class WebSocketListener<T extends Application> {
public abstract path(): string;
public abstract async handle(socket: WebSocket, request: IncomingMessage, session: Express.SessionData | null): Promise<void>;
public abstract async handle(socket: WebSocket, request: IncomingMessage, session: Express.Session | null): Promise<void>;
}

View File

@ -13,7 +13,7 @@ export default class MagicLinkWebSocketListener extends WebSocketListener<any> {
}
}
async handle(socket: WebSocket, request: IncomingMessage, session: Express.SessionData | null): Promise<void> {
async handle(socket: WebSocket, request: IncomingMessage, session: Express.Session | null): Promise<void> {
// Drop if requested without session
if (!session) {
socket.close(1002, 'Session is required for this request.');

View File

@ -66,7 +66,7 @@ export default class WebSocketServerComponent extends ApplicationComponent<void>
session.id = sid;
store.createSession(<Request>request, session);
listener.handle(socket, request, session).catch(err => {
listener.handle(socket, request, <Express.Session>session).catch(err => {
Logger.error(err, 'Error in websocket listener.');
});
});