Reputation: 353
I have implemented quickblox chat in my web application. Now I want to show status of my messages as delivered
in case when they are just sent to user and as read
when they have seen the message.
In your Javascript SDK I have found two functions QB.chat.sendDeliveredMessage
and QB.chat.sendReadMessage
but every time I call this function as :
QB.chat.sendDeliveredMessage(
QBChatHelpers.getJID(chatUser.id),
"5600f885a28f9ac7e801048c" //this is just a sample msg-id
);
It calls ajax with POST
request over url http://chat.quickblox.com:8080/
while chat is running over http://chat.quickblox.com:5280/
.
Also within library, I changed the port to 5280 in place of 8080 so that it can call url with port 8080
and it calls http://chat.quickblox.com:5280/
which then gives error code 405: Invalid Hostname
.
Please let me know what's wrong am I doing while calling this function. If further information is required then do let me know.
Upvotes: 2
Views: 1313
Reputation: 3079
Thanks guys, this page helped me a lot.
When a message is sent could be 2 options:
OPTION A:
Send your message to the addressee with "markable=1" flag. For example:
var params = {
chat_dialog_id: "56b20540f583bb7bcb00rrr6",
message: msg),
send_to_chat: 1,
markable: 1,
extension: {
save_to_history: 1
}
};
// SEND THE MESSAGE
QB.chat.message.create(params, function (err, res) {});
Add QB listener to be trigger after the addressee user had read the message:
QB.chat.onReadStatusListener = updateReadersList;
And then add such a function with this signature:
function updateReadersList(messageId, dialogId, userId){
console.log('userId has read your messageId that in dialogId');
}
OPTION B:
Add QB listener to handle new incoming messages:
QB.chat.onMessageListener = showMessage;
Add such a listener function with this signature: In that listener you can notify the sender that his message was recived an d read (by you):
function showMessage(userId, msg) {
console.log('userId sent you this msg');
//notify sender: message was read:
if(userId != "MY-USER") {
sendReadSignalToSender(msg, userId);
console.log("You notified userId that his msg was read.");
}
}
Adding a simple function for just passing params to QB.chat.sendReadStatus function:
function sendReadSignalToSender(dialogMsg, senderId){
var params = {
messageId: (dialogMsg.id || dialogMsg._id),
userId: senderId,
dialogId: (dialogMsg.dialog_id || dialogMsg.chat_dialog_id)
};
QB.chat.sendReadStatus(params);
console.log("senderId was notified that his dialogMsg was read.");
}
Upvotes: 0
Reputation: 189
We are working on this feature, in the new version of QuickBlox JS SDK messages will be sent with the markable status. sendDeliveredStatus(params)-will be sent automatically after receiving a message with markable status, which will signalize via the function of Listener QB.chat.onDeliveredStatusListener(messageId, dialogId, userId);
sendReadStatus(params)-will be possible to send it according to an event (for example, you set up a processor, which will notice that a message has already appeared on yours monitor, after receiving a message with markable status, which will signalize via the function of Listener QB.chat.onReadStatusListener(messageId, dialogId, userId);)
parameters for status sending:
params = {
messageId: messageId,
userId: userId,
dialogId: dialogId
};
Upvotes: 1