Skip to content

notificaciones... #1

@marcelklehr

Description

@marcelklehr

https://github.com/antoniopol06/gitnode/blob/master/notificaciones/routes/index.js#L91 :

var io=require('../variables').io;
      //sockets
      io.sockets.on('connection', inicio);
      function inicio(socket){
      var socketid = notificaciones[usuarioFinal];
      if (typeof socketid == 'undefined' || usuario==usuarioFinal)
      {
        console.log("no emitir");
      }else{
        io.sockets.socket(socketid).emit('notificar', usuario, mensaje);
      }

      }

This needs to be put to top-level, since you don't wnat it to be executed everytime someone accesses that url (and triggers that express handler for contestarTema).

So, when a new reply comes in, I'd push that to some user-specific array that contains all unread messages of that particular user. and on top level (aka line 0), I'd set up io.on('connection', inicio), where inicio checks that particular user's array for unread messages and sends them to the client.

cheers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions