Socket.io : "cannot Read Property 'emit' Of Undefined"
So I'm currently developping my website using socket.io. Today, while I was implementing the sockets, I got a nice little error 'Cannot read property 'emit' of undefined' I can not
Solution 1:
Client Code:
Change
// Connection established
socket.on('connect', function(socket) {
to
// Connection established
socket.on('connect', function(data) {
final:
// Connection established
socket.on('connect', function(data) {
$('.connect_error').hide();
$('.connected').show();
console.log(data);
socket.emit('create_socket', '<?= $port; ?>');
});
Previously, you where overwriting the socket object.
Post a Comment for "Socket.io : "cannot Read Property 'emit' Of Undefined""