Send request along with websocket instance
MODIFY
lib/express/websocket.js
lib/express/websocket.js
@@ -34,7 +34,7 @@ async function addWebSocketHandler (handlerPathname, handlerServer) {
for (const [pathname, wsServer] of _.toPairs(this.webSocketsMapping)) {
if (currentPathname === pathname) {
wsServer.handleUpgrade(request, socket, head, (ws) => {
- wsServer.emit('connection', ws);
+ wsServer.emit('connection', ws, request);
});
return;
}

MODIFY
test/basedriver/websockets-e2e-specs.js
test/basedriver/websockets-e2e-specs.js
@@ -43,6 +43,10 @@ describe('Websockets (e2e)', function () {
_.keys(await baseServer.getWebSocketHandlers()).length.should.eql(1);
await new B((resolve, reject) => {
const client = new WebSocket(`ws://localhost:${PORT}${endpoint}`);
+ client.on('connection', (ws, req) => {
+ ws.should.not.be.empty;
+ req.connection.remoteAddress.should.not.be.empty;
+ });
client.on('message', (data) => {
data.should.eql(WS_DATA);
resolve();

Send request along with websocket instance (#200)