From f52dea0e13bbc91b8f7ed20564a328b9130728d9 Mon Sep 17 00:00:00 2001 From: John McLear Date: Sat, 7 Nov 2020 13:30:48 +0000 Subject: [PATCH] just a demo including padid in header --- src/static/js/pad.js | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/static/js/pad.js b/src/static/js/pad.js index 4dc7d0884..e4b00a247 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -219,7 +219,31 @@ const sendClientReady = (isReconnect, messageType) => { }; const handshake = () => { - socket = pad.socket = socketio.connect(exports.baseURL, '/', { + + var padId = document.location.pathname.substring(document.location.pathname.lastIndexOf("/") + 1); + +// demo, needs refactor + +socket = pad.socket = io({ + transportOptions: { + polling: { + extraHeaders: { + 'x-padId': padId + } + } + } +}); + + socket = pad.socket = socket.connect(url, { + + handlePreflightRequest: function (req, res) { + var headers = { + 'padId': "derp" + }; + res.writeHead(200, headers); + res.end(); + }, + reconnectionAttempts: 5, reconnection: true, reconnectionDelay: 1000,