just a demo including padid in header

socket-padid-in-header
John McLear 2020-11-07 13:30:48 +00:00 committed by Richard Hansen
parent 95e8ae1900
commit f52dea0e13
1 changed files with 25 additions and 1 deletions

View File

@ -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,