- Easily and quickly get started with adding instant messaging to your application.
- Everything is asynchronous, works with await.
- Small codebase with zero third-party dependencies (except mongodb)
- MongoDB
- Application logic that has a working and trusted authentication mechanism.
Install and start the server.
npm install mongodb_instant_messenger
instant_messenger = require('mongodb_instant_messenger');
This will return an array of objects which is the user's inbox.
await inbox(Readers_Profile_ID_From_Trusted_Authentication_Process);
Example of returned data. As you can see you get the makeup of an inbox. Inside your application you must include profile images and other useful information so the end user can understand who the message is coming from.
[
{
_id: new ObjectId("61c10a57108e95476ea51b70"),
sender: new ObjectId("61c108d4108e95476ea51b6c"),
content: 'test message 2',
unread: true,
timestamp: 2022-03-18T01:53:11.051Z
},
{
_id: new ObjectId("61d8daca4b19c40ac4a0206a"),
sender: new ObjectId("61c108d4108e95476ea51b6c"),
content: 'test message 1',
unread: false,
timestamp: 2022-01-11T10:24:04.871Z
}
]
const messageID = await instant_messenger.sendMessage(message, Other_Users_ProfileID, Readers_Profile_ID_From_Trusted_Authentication_Process);
await instant_messenger.markRead(Other_Users_ProfileID, Readers_Profile_ID_From_Trusted_Authentication_Process);