deepstreamIO / deepstream.io-client-js

The Browser / Node.js Client for deepstream.io
Other
294 stars 109 forks source link

Issue an event to a user by their ID #573

Closed luisalfredosv closed 2 years ago

luisalfredosv commented 2 years ago

I really don't know where to ask this or if it's possible to do it, but I'm making a chat application and I need to send direct messages between users, so I've researched and read the documentation and I really can't find anything about it.

Thank you for clarifying this doubt

jaime-ez commented 2 years ago

Hi, you should use events if you have a chat app, then I assume you have contacts. Every user can have an open event channel, for example, start-chat-withme-$userId. So if user A is contact of user B, both will know each others userIds and therefore ping each other on that event channel. Once the chat request is made and accepted, they can set up an exclusive channel for both of them by creating another event space (chat/$randomChatId) end send/listen to event messages on that channel.

Or, if you wan to persist messages, instead of events, you can set up a record list, and then each individual message is a record added to the list, so if both users subscribe to the list, they will read each other messages by getting each record data.

Hope it helps