Pass a whole Session to WebSocketListeners
This commit is contained in:
parent
6305a69583
commit
79d3b51f90
@ -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>",
|
||||
|
@ -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>;
|
||||
}
|
@ -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.');
|
||||
|
@ -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.');
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user