I’m trying to communicate with the glitch server but i seem to keep getting the same error(I properly installed socket.io onto the server)
glitch error: TypeError: Cannot read property ‘on’ of undefined
glitch code
var server = require('http').createServer();
var io = require('socket.io')(server);
io.sockets.on('connection', function(socket) {
console.log("Client has connected!");
});
io.socket.on ('playerJoined', function (name) {
^
(error)
console.log (name);
});
console.log ('Server started.');
server.listen(3000);
playcanvas code
var Network = pc.createScript('Network');
// initialize code called once per entity
Network.prototype.initialize = function() {
this.socket = io.connect('https://gun-game-server.glitch.me');
};
// update code called every frame
Network.prototype.update = function(dt) {
this.socket.emit ('playerJoined', 'John');
};