Repaired emit broadcaster
This commit is contained in:
parent
8ee0d9d122
commit
d5d93a126a
3
index.js
3
index.js
@ -9,6 +9,7 @@ app.use(express.static(__dirname + '/public'));
|
|||||||
|
|
||||||
function onConnection(socket){
|
function onConnection(socket){
|
||||||
socket.on('input', function(data) {
|
socket.on('input', function(data) {
|
||||||
|
console.log(data);
|
||||||
var command = data.split(" ");
|
var command = data.split(" ");
|
||||||
if (command.lenght() == 4) {
|
if (command.lenght() == 4) {
|
||||||
if (command[0] == "PX") {
|
if (command[0] == "PX") {
|
||||||
@ -16,7 +17,7 @@ function onConnection(socket){
|
|||||||
var y = parseInt(command[2]);
|
var y = parseInt(command[2]);
|
||||||
if (!isNaN(x) && !isNaN(y)) {
|
if (!isNaN(x) && !isNaN(y)) {
|
||||||
var color = command[3]
|
var color = command[3]
|
||||||
socket.broadcast.emit('draw', {type: 'pixel', x: x, y: y, color: color}}));
|
socket.broadcast.emit('draw', {type: 'pixel', x: x, y: y, color: color});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user