diff --git a/public/data/scripts/online.js b/public/data/scripts/online.js index eb2e600..4ce23dd 100644 --- a/public/data/scripts/online.js +++ b/public/data/scripts/online.js @@ -2,36 +2,35 @@ function socketConnect(project, name = "noone"){ let urlQueries = '?game=' + project.name + '&name=' + name; - $.get('data/settings/get_port.php', port => { - let url = 'https://' + location.hostname + ':' + port + urlQueries; + let url = 'https://' + location.hostname + urlQueries; + socket = io.connect(url, { + path: "/global-draw/" + }); + socket.on('connect', () => { + console.log('Connected to ', url); - socket = io.connect(url); - socket.on('connect', () => { - console.log('Connected to ', url); + socket.emit('join-lobby', 'global-draw-room'); - socket.emit('join-lobby', 'global-draw-room'); + socket.on('add-line', (lobby, line) => drawer.addLine(line)); + socket.on('fill-pixel', (lobby, pixel) => drawer.fillPixel(pixel)); + socket.on('add-all', (lines) => drawer.onLinesLoaded(lines)); + socket.on('fill-all', (pixels) => drawer.onPixelsLoaded(pixels)); + socket.on('member-joined', (lobby, clientId) => { + if (clientId !== socket.id) + return; + if (drawer) + if (drawer.lines.length !== 0) + return; - socket.on('add-line', (lobby, line) => drawer.addLine(line)); - socket.on('fill-pixel', (lobby, pixel) => drawer.fillPixel(pixel)); - socket.on('add-all', (lines) => drawer.onLinesLoaded(lines)); - socket.on('fill-all', (pixels) => drawer.onPixelsLoaded(pixels)); - socket.on('member-joined', (lobby, clientId) => { - if (clientId !== socket.id) - return; - if (drawer) - if (drawer.lines.length !== 0) - return; + socket.emit('request-all-lines'); + socket.emit('request-all-pixels'); + $("#action").html("Downloading..."); + }); - socket.emit('request-all-lines'); - socket.emit('request-all-pixels'); - $("#action").html("Downloading..."); - }); + socket.on('all-saved', (_lobby) => drawer.answerServerSave()); - socket.on('all-saved', (_lobby) => drawer.answerServerSave()); - - updateDrawType($("input[type=radio][name=type]:checked").val()); - }); - }); + updateDrawType($("input[type=radio][name=type]:checked").val()); + }); } function sendFeedback(){ diff --git a/public/data/settings/get_port.php b/public/data/settings/get_port.php deleted file mode 100644 index 8de971e..0000000 --- a/public/data/settings/get_port.php +++ /dev/null @@ -1,3 +0,0 @@ - connectionManager.newSocket(socket)); - log('startup', null, null, 'Server is listening on port ' + httpsPort); + log('startup', null, null, 'Server is listening on port ' + settings.port); } \ No newline at end of file