Question

I'm trying to get this exmaple working on my own computer:

https://github.com/tamaspiros/simple-chat

I have node.js installed and have installed socket.io as well. The readme is informing me to change the IP addresses on these two lines:

var socket = io.listen(1223, "1.2.3.4");
var socket = io.connect("1.2.3.4:1223");

However, I'm not really sure what to change the IP addresses into. I would like to get the simple chat box application working on my own computer.

Was it helpful?

Solution

You just need to configure it in one like, for ie:

var socket = io.connect('adress:port');

where addres is Your socket.io server IP or hostname, and yyyy is port on which it listens.

after that, You can get and emit events with:

  socket.on('news', function (data) {
    console.log(data);
    socket.emit('my other event', { my: 'data' });
  });

on server listen for

and thats it.

Before making chat You can try just using this example from official socket.io: link

PS dont forget to add socket.io client file source on client side! :). The whole code should look like in the example in the provided link.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top