Hi,
Since I added to my project socket.io I have this error when I want to open a file.
Uncaught ReferenceError: sock is not defined jquery-1.7.1.min.js:4
My class where I use soket.io :
link
And index.html
link
Thx for your help.
Is it possible that there is a conflict because JQuery and Socket.io both have an .on() method ?
sock.on('addNetPlayer',function(x, y, index){
console.log('addNetPlayer called');
var newplayer = ig.game.spawnEntity(EntityNetPlayer,x,y);
newplayer.id= index;
players.push(newplayer);
sock.emit('doYouKnowMe', self.id, self.pos.x, self.pos.y);
console.log(x+' '+y+' '+' '+id);
});
I also saw this
socket IO anonymous .on() functions cant use jquery
I asked there :
stack
But now I have other errors :
Uncaught SyntaxError: Unexpected token . localhost/:35
Uncaught TypeError: Cannot read property 'emit' of undefined Player.js:52
My new files :
Player.js :
here
index.html :
here
1 decade ago
by Joncom
@papyhardcore: ZIP up your game (excluding the
/lib/impact
folder) and upload it to
http://upea.se so we can take a closer look. And if necessary provide instruction on how to produce the error.
Hi, I find the problem.
Socket is loaded in index.html and not in Player.js.
Map editor can't load socket.
To solve this problem in Player.js :
if (typeof sock != 'undefined')
sock.emit('update', this.padmap, this.id);
Page 1 of 1
« first
« previous
next ›
last »