Thursday 8 June 2017

Configuring socket.io for node.js application

I have a few questions about configuring socket.io for my node.js application.

  1. When requiring var socket = require('socket.io')( /* HERE */ ), do I need to input the port my server listens where the /* HERE */ is at?

  2. Right below that line, I have another require, for a .js file that contains a few constants and a function. However when I try to refer to 'socket' in that file it says it's undefined? But since this line is below the require line for the socket.io middleware, why does it say 'undefined'?

  3. For configuring client-side socket.io, I added this line:

    var socket = io.connect('https://mydomain')
    
    

    Do I need to say 'mydomain:port' or 'mydomain' is enough?



via konyv12

No comments:

Post a Comment