0

I am using node.js for backend and angular for frontend...

I thought to use socket.io but I am not sure how how to handle comunication between users...

For example how can I push message message to specific user after message is saved to database?

ex.

router.post('/message', function(req, res) {

    Message.create({
            text: req.body.text,
            fromUser: req.fromToken.id,
            toUser: req.body.toUser   
          }, function(err,message) {
             //FROM HERE WHAT IS THE BEST WAY TO PUSH MESSAGE TO USER  
          })

});
Vladimir
  • 1,751
  • 6
  • 30
  • 52
  • For socket.io, check out the chat room tutorial on their website - http://socket.io/get-started/chat/ – dan Nov 11 '16 at 10:24
  • Already checked it, but there is no express routes and they send message to all users not to specific one... – Vladimir Nov 11 '16 at 10:38
  • Could you please be a little more specific in your question, for sending a message to a specific user, there is already an answer here http://stackoverflow.com/questions/17476294/how-to-send-a-message-to-a-particular-client-with-socket-io – Akil Nov 11 '16 at 11:06

0 Answers0