Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Socket Listener on same port. #53

Open
prabhatbharat opened this issue May 4, 2021 · 0 comments
Open

Adding Socket Listener on same port. #53

prabhatbharat opened this issue May 4, 2021 · 0 comments

Comments

@prabhatbharat
Copy link

Hi,

I was wondering to add socket.io on the same port, something like this.

const app = require('./index.js');
const port = process.env.PORT;

// Server
let server = app.listen(port, () => {
  console.log(`Listening TCP on: http://localhost:${port}`);
});

let io     = require('socket.io')(server);
console.log(` WS on: http://localhost:${port}`);
io.on('connection', (socket) => {
  console.log('IO user connected');
});

I need some ideas to create routes for socket IO. I am not able to figure out that routing mechanism.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant