How to trace a message from a large number of dialogs using socket.io?

  • 0
    Hello! I want to implement a chat page for my application. The logic will be as follows: when a user goes to the chat page, all his dialogs are displayed to him. After all dialogs are displayed by dialogId, I connect them all in sockets. My question is:
    how can I catch a message if someone writes me from my dialogues?

    1) I get the Id of all dialogs
    2) By these Id I connect to the rooms.
    3) How can I track if someone writes me a message from any of these dialogs?
    Frontend
    useEffect(() => {
        const dialogsId = dialogList.map(value => value.dialogId)
       	socket.emit('joinDialogs',  dialogsId);
      }, [dialogList]);

    Backend
    socket.on('joinDialogs', (dialogsId) => {
        socket.join(dialogsId);
      });
    JavaScript Archer Soto, Jul 11, 2020

  • 0 Answers
Your Answer
To place the code, please use CodePen or similar tool. Thanks you!