Pubnub Overview - Glia-mh/Glia-Web-Client GitHub Wiki
Pubnub is a service that easily allows apps to transfer data via sockets, in real time. It works on a subscribe / publish model, i.e. Apps can subscribe to what are known as channels, and publish messages on those channels, which all clients subscribed to a given channel can then receive
Note, official documentation: https://www.pubnub.com/docs/react-native-javascript/pubnub-javascript-sdk
Pubnub is only used to connect between clients. The database does not interact with pubnub in any way whatsoever. Pubnub is only used for the chat functionality.
To organize the channels, each of them is labeled sequentially, as Conversation 1, Conversation 2, .... Conversation N, and so on. Each channel corresponds to one chat, which has one counselor and 4 people.
Another important thing is the format of the messages being sent. Because of libraries chosen for React Native, the messages must be sent in the following format:
_id: guid(),
createdAt: new Date(),
text: message,
user : {
_id: 0,
avatar: "https://www.timeshighereducation.com/sites/default/files/byline_photos/defaultavatar.png"
}