|
|
@ -2,36 +2,35 @@ |
|
|
|
|
|
|
|
|
|
|
|
function socketConnect(project, name = "noone"){ |
|
|
|
function socketConnect(project, name = "noone"){ |
|
|
|
let urlQueries = '?game=' + project.name + '&name=' + name; |
|
|
|
let urlQueries = '?game=' + project.name + '&name=' + name; |
|
|
|
$.get('data/settings/get_port.php', port => { |
|
|
|
let url = 'https://' + location.hostname + urlQueries; |
|
|
|
let url = 'https://' + location.hostname + ':' + port + urlQueries; |
|
|
|
socket = io.connect(url, { |
|
|
|
|
|
|
|
path: "/global-draw/" |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
socket.on('connect', () => { |
|
|
|
|
|
|
|
console.log('Connected to ', url); |
|
|
|
|
|
|
|
|
|
|
|
socket = io.connect(url); |
|
|
|
socket.emit('join-lobby', 'global-draw-room'); |
|
|
|
socket.on('connect', () => { |
|
|
|
|
|
|
|
console.log('Connected to ', url); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.emit('request-all-lines'); |
|
|
|
socket.on('fill-pixel', (lobby, pixel) => drawer.fillPixel(pixel)); |
|
|
|
socket.emit('request-all-pixels'); |
|
|
|
socket.on('add-all', (lines) => drawer.onLinesLoaded(lines)); |
|
|
|
$("#action").html("Downloading..."); |
|
|
|
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.on('all-saved', (_lobby) => drawer.answerServerSave()); |
|
|
|
socket.emit('request-all-pixels'); |
|
|
|
|
|
|
|
$("#action").html("Downloading..."); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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(){ |
|
|
|
function sendFeedback(){ |
|
|
|