Fix session id not available in websocket listeners

Fixes #21
This commit is contained in:
Alice Gaudon 2021-01-25 16:36:15 +01:00
parent 8b98c8cc59
commit 4745ae4e17

View File

@ -10,6 +10,7 @@ import Application from "../Application";
import RedisComponent from "./RedisComponent"; import RedisComponent from "./RedisComponent";
import WebSocketListener from "../WebSocketListener"; import WebSocketListener from "../WebSocketListener";
import NunjucksComponent from "./NunjucksComponent"; import NunjucksComponent from "./NunjucksComponent";
import {Session} from "express-session";
export default class WebSocketServerComponent extends ApplicationComponent { export default class WebSocketServerComponent extends ApplicationComponent {
private wss?: WebSocket.Server; private wss?: WebSocket.Server;
@ -65,7 +66,7 @@ export default class WebSocketServerComponent extends ApplicationComponent {
session.id = sid; session.id = sid;
store.createSession(<Request>request, session); store.createSession(<Request>request, session);
listener.handle(socket, request, (<Request>request).session).catch(err => { listener.handle(socket, request, session as Session).catch(err => {
logger.error(err, 'Error in websocket listener.'); logger.error(err, 'Error in websocket listener.');
}); });
}); });