Jump to content
MakeWebGames

Socket.io Difficulties


Recommended Posts

I'm having some difficulties getting socket.io up and running.

It doesn't seem to be emitting events on the client side and when I load up dev tools in chrome I see this:

Gy7DtfQ.png

my code is this:

 

<script src="https://cdn.socket.io/socket.io-1.3.5.js"></script>
<script>$(document).ready(function(){
var socket = io();
$("#entry").click(function() {
	socket.emit("connect", "USER");
});
});</script>

 

and yes, I have socket.io 1.3.5 installed.

any ideas?

Link to post
Share on other sites

I had to uninstall and reinstall the node_modules then in my server code:

var express = require('express');
var app = express();
var http = require('http').createServer(app);
var server = app.listen(3000);
var io = require('socket.io').listen(server);

 

client:

<script src='/socket.io/socket.io.js'></script>
<script>
var socket = io.connect();
</script>
  • Like 1
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...