Monday, 13 March 2017

How to socket.io with express generator? Individual socket, for individual link

I have typical express-generator app. In my controllers folder I have code:

        router.get('/:id([A-Za-z0-9_]{5,25})', function(req, res, next) {
            res.render('my-page.html', { title: 'Messages'});
             //How to implement socket.io code for this page?
            /*
             io.on('connection', function(socket){
                 console.log('a user connected');
             });
           */
        });

I tried simple guide from socket.io website and from stackoverflow advices, but it isn't working. Try to imagine, that here is many different chat rooms, and for every room, I need to open individual socket... I know how to make it global, but have no idea, how to make personal socket, for personal page...



via Bim Bam

No comments:

Post a Comment