ConnectyCube / connectycube-web-samples

Chat and Video Chat code samples for Web, based on ConnectyCube platform
https://connectycube.com
Apache License 2.0
18 stars 29 forks source link

sendReadStatus(params) is not working #130

Open huahengling opened 2 years ago

huahengling commented 2 years ago

Hi, I need some help here. I use public chat mode for my project and I try to send the read status for message from server to mobile (iOS and Android) but they could not receive it. Below is the code

const params = {
  messageId: "557f1f22bcf86cd784439022",
  userId: 21,
  dialogId: "5356c64ab35c12bd3b108a41",
};

ConnectyCube.chat.sendReadStatus(params);

If mobile side send read status to server side, it works

huahengling commented 2 years ago

Hi @ccvlad could you help please ?

ccvlad commented 2 years ago

Hi, @huahengling ! Are you expecting to get read status in real time (onReadStatusListener should get the status)? Could you show logs on the moment of sending the status from both sides?

huahengling commented 2 years ago

I expect mobile side (iOS and Android) able to receive read acknowledgement from the server. But mobile side did not receive it.

This is the log when server send "sendReadStatus" to mobile side sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "60fe738cee05e11ac0000003", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"}dialogId: "60110656ca8bf470b0aabe34"messageId: "60fe738cee05e11ac0000003"userId: "3810831"[[Prototype]]: Object sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "60fe7399a8c6fcb6108d79f9", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "60fe73b2ee05e11ac0000007", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "60fe73c7ee05e11ac0000008", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "61002db420b3e30028b39b67", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "6100c31c2cec46ee030041aa", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "6100c5e72dff2b2c7f000003", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "6100c602dba4d16e80e0200b", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "6100d4e32dff2b2c7f000007", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "6100d54d2dff2b2c7f000008", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "610109dd6e38fc69e2000014", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "610109fc4624828320cd823f", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "610263f92cec461104004270", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} sophydChat.js:430 [ConnectyCube.chat.onReadStatusListener] callback: 60fe738cee05e11ac0000003 60110656ca8bf470b0aabe34 3810831 sophydChat.js:430 [ConnectyCube.chat.onReadStatusListener] callback: 60fe7399a8c6fcb6108d79f9 60110656ca8bf470b0aabe34 3810831 sophydChat.js:430 [ConnectyCube.chat.onReadStatusListener] callback: 60fe73b2ee05e11ac0000007 60110656ca8bf470b0aabe34 3810831 sophydChat.js:430 [ConnectyCube.chat.onReadStatusListener] callback: 60fe73c7ee05e11ac0000008 60110656ca8bf470b0aabe34 3810831 sophydChat.js:430 [ConnectyCube.chat.onReadStatusListener] callback: 61002db420b3e30028b39b67 60110656ca8bf470b0aabe34 3810831 sophydChat.js:430 [ConnectyCube.chat.onReadStatusListener] callback: 6100c31c2cec46ee030041aa 60110656ca8bf470b0aabe34 3810831 sophydChat.js:430 [ConnectyCube.chat.onReadStatusListener] callback: 6100c5e72dff2b2c7f000003 60110656ca8bf470b0aabe34 3810831 sophydChat.js:430 [ConnectyCube.chat.onReadStatusListener] callback: 6100c602dba4d16e80e0200b 60110656ca8bf470b0aabe34 3810831 sophydChat.js:430 [ConnectyCube.chat.onReadStatusListener] callback: 6100d4e32dff2b2c7f000007 60110656ca8bf470b0aabe34 3810831 sophydChat.js:430 [ConnectyCube.chat.onReadStatusListener] callback: 6100d54d2dff2b2c7f000008 60110656ca8bf470b0aabe34 3810831 sophydChat.js:430 [ConnectyCube.chat.onReadStatusListener] callback: 610109dd6e38fc69e2000014 60110656ca8bf470b0aabe34 3810831 sophydChat.js:430 [ConnectyCube.chat.onReadStatusListener] callback: 610109fc4624828320cd823f 60110656ca8bf470b0aabe34 3810831 sophydChat.js:430 [ConnectyCube.chat.onReadStatusListener] callback: 610263f92cec461104004270 60110656ca8bf470b0aabe34 3810831 Fetch finished loading: GET "<URL>". Fetch finished loading: GET "<URL>". Fetch finished loading: GET "<URL>". Fetch finished loading: GET "<URL>". Fetch finished loading: GET "<URL>". sophydChat.js:357 [ConnectyCube.chat.onMessageTypingListener] callback: true 4015716 5fb73008ca8bf43c070ea98d sophydChat.js:357 [ConnectyCube.chat.onMessageTypingListener] callback: true 4015716 5fb73008ca8bf43c070ea98d sophydChat.js:357 [ConnectyCube.chat.onMessageTypingListener] callback: false 4015716 5fb73008ca8bf43c070ea98d sophydChat.js:367 [ConnectyCube.chat.onMessageListener] callback: 4015716 {id: "61026a7fd4b79c1db5000000", dialog_id: "5fb73008ca8bf43c070ea98d", recipient_id: null, type: "groupchat", body: "hi", …} app.js:7165 list Dialogs??? app.js:2351 *** call for get unread status ***

this is the log from the iOS user when they send message to the server. Mobile side can receive delivered status only, but not read status.

2021-07-29 16:55:27.080405+0800 Reno[3803:1001818] [Chat]: SNT: <message id="61026cffa58b1fdb0e0041ab" to="3571_5fb73008ca8bf43c070ea98d@muc.chat.connectycube.com" type="groupchat">
  <body>Hi</body>
  <extraParams xmlns="jabber:client">
    <save_to_history>1</save_to_history>
    <date_sent>1627548927</date_sent>
    <dialog_id>5fb73008ca8bf43c070ea98d</dialog_id>
  </extraParams>
  <markable xmlns="urn:xmpp:chat-markers:0"/>
</message>
2021-07-29 16:55:27.084480+0800 Reno[3803:1001640] [Chat]: SNT: ack request
2021-07-29 16:55:27.380320+0800 Reno[3803:1001640] [Chat]: RCV: <message xmlns="jabber:client" from="3571_5fb73008ca8bf43c070ea98d@muc.chat.connectycube.com/2734771" id="61026cffa58b1fdb0e0041ab" to="2734771-3571@chat.connectycube.com" type="groupchat">
  <body>Hi</body>
  <extraParams xmlns="jabber:client">
    <save_to_history>1</save_to_history>
    <date_sent>1627548927</date_sent>
    <dialog_id>5fb73008ca8bf43c070ea98d</dialog_id>
    <message_id>61026cffa58b1fdb0e0041ab</message_id>
  </extraParams>
  <markable xmlns="urn:xmpp:chat-markers:0"/>
  <delay xmlns="urn:xmpp:delay" stamp="2021-07-29T08:55:27Z"/>
</message>
2021-07-29 16:55:27.995530+0800 Reno[3803:1001818] [Chat]: RCV: ack 1
ccvlad commented 2 years ago

try on the server side:

ConnectyCube.chat.onMessageListener = (userId, message) => {
  /*
   * Some your code here...
   */

  const params = {
    messageId: message.id,
    userId: userId, // current message sender's ID
    dialogId: message.dialog_id,
  };

  console.log('Params to send read status:', params);

  ConnectyCube.chat.sendReadStatus(params);
}

here you'll get message from mobile and immediately send read status back.

Also you are able to switch on ConnectyCube's log by the guide (add debug: {mode: 1}).

huahengling commented 2 years ago

try on the server side:

ConnectyCube.chat.onMessageListener = (userId, message) => {
  /*
   * Some your code here...
   */

  const params = {
    messageId: message.id,
    userId: userId, // current message sender's ID
    dialogId: message.dialog_id,
  };

  console.log('Params to send read status:', params);

  ConnectyCube.chat.sendReadStatus(params);
}

here you'll get message from mobile and immediately send read status back.

Also you are able to switch on ConnectyCube's log by the guide (add debug: {mode: 1}).

Still the same issue. Here is the log

cubeInternalUtils.js:116 [Chat] SENT: <presence id="212d1da0-f6a7-4f51-9baa-44c3bb5384fe:join" from="3810831-3571@chat.connectycube.com/1206818911-chat-179693" to="3571_60110656ca8bf470b0aabe34@muc.chat.connectycube.com/3810831" xmlns="jabber:client"><x xmlns="http://jabber.org/protocol/muc"><history maxstanzas="0"/></x></presence> cubeInternalUtils.js:116 [Request][209] GET https://api.connectycube.com/chat/Message.json {url: "https://api.connectycube.com/chat/Message.json", data: {…}} cubeInternalUtils.js:116 [Chat] RECV: <presence from="3571_60110656ca8bf470b0aabe34@muc.chat.connectycube.com/3810831" xmlns="jabber:client" id="212d1da0-f6a7-4f51-9baa-44c3bb5384fe:join" to="3810831-3571@chat.connectycube.com/1206818911-chat-179693"><x xmlns="http://jabber.org/protocol/muc#user"><item nick="3810831" affiliation="admin" role="moderator" jid="3810831-3571@chat.connectycube.com/1206818911-chat-179693"/><status code="110"/><status code="100"/></x></presence> cubeInternalUtils.js:116 [Chat] RECV: <r xmlns='urn:xmpp:sm:3' /> cubeInternalUtils.js:116 [Chat] SENT: <a xmlns="urn:xmpp:sm:3" h="5"/> cubeInternalUtils.js:116 [Response][209] {skip: 0, limit: 50, items: Array(50)}items: (50) [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]limit: 50skip: 0[[Prototype]]: Object sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "6102d09720b3e30028b3c1ae", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} cubeInternalUtils.js:116 [Chat] SENT: <message type="chat" from="3810831-3571@chat.connectycube.com/1206818911-chat-179693" to="3810831-3571@chat.connectycube.com" id="610376678ad533024f000000" xmlns="jabber:client"><displayed xmlns="urn:xmpp:chat-markers:0" id="6102d09720b3e30028b3c1ae"/><extraParams xmlns="jabber:client"><dialog_id>60110656ca8bf470b0aabe34</dialog_id></extraParams></message> sophydChat.js:418 [ConnectyCube.chat.sendReadStatus] callback: {messageId: "6102d0a020b3e30028b3c1af", userId: "3810831", dialogId: "60110656ca8bf470b0aabe34"} cubeInternalUtils.js:116 [Chat] SENT: <message type="chat" from="3810831-3571@chat.connectycube.com/1206818911-chat-179693" to="3810831-3571@chat.connectycube.com" id="610376678ad533024f000001" xmlns="jabber:client"><displayed xmlns="urn:xmpp:chat-markers:0" id="6102d0a020b3e30028b3c1af"/><extraParams xmlns="jabber:client"><dialog_id>60110656ca8bf470b0aabe34</dialog_id></extraParams></message> cubeInternalUtils.js:116 [Request][210] GET https://api.connectycube.com/users/by_login.json {type: "GET", url: "https://api.connectycube.com/users/by_login.json", data: {…}} cubeInternalUtils.js:116 [Request][211] GET https://api.connectycube.com/users/by_login.json {type: "GET", url: "https://api.connectycube.com/users/by_login.json", data: {…}} cubeInternalUtils.js:116 [Request][212] GET https://api.connectycube.com/users/by_login.json {type: "GET", url: "https://api.connectycube.com/users/by_login.json", data: {…}} cubeInternalUtils.js:116 [Request][213] GET https://api.connectycube.com/users/by_login.json {type: "GET", url: "https://api.connectycube.com/users/by_login.json", data: {…}} cubeInternalUtils.js:116 [Request][214] GET https://api.connectycube.com/chat/Message.json {url: "https://api.connectycube.com/chat/Message.json", data: {…}} cubeInternalUtils.js:116 [Chat] RECV: <message from="3810831-3571@chat.connectycube.com/1206818911-chat-179693" xmlns="jabber:client" type="chat" to="3810831-3571@chat.connectycube.com" id="610376678ad533024f000000"><displayed xmlns="urn:xmpp:chat-markers:0" id="6102d09720b3e30028b3c1ae"/><extraParams xmlns="jabber:client"><dialog_id>60110656ca8bf470b0aabe34</dialog_id></extraParams></message> sophydChat.js:429 [ConnectyCube.chat.onReadStatusListener] callback: 6102d09720b3e30028b3c1ae 60110656ca8bf470b0aabe34 3810831 cubeInternalUtils.js:116 [Chat] RECV: <r xmlns='urn:xmpp:sm:3' /> cubeInternalUtils.js:116 [Chat] SENT: <a xmlns="urn:xmpp:sm:3" h="6"/> cubeInternalUtils.js:116 [Chat] RECV: <message from="3810831-3571@chat.connectycube.com/1206818911-chat-179693" xmlns="jabber:client" type="chat" to="3810831-3571@chat.connectycube.com" id="610376678ad533024f000001"><displayed xmlns="urn:xmpp:chat-markers:0" id="6102d0a020b3e30028b3c1af"/><extraParams xmlns="jabber:client"><dialog_id>60110656ca8bf470b0aabe34</dialog_id></extraParams></message> sophydChat.js:429 [ConnectyCube.chat.onReadStatusListener] callback: 6102d0a020b3e30028b3c1af 60110656ca8bf470b0aabe34 3810831 cubeInternalUtils.js:116 [Chat] RECV: <r xmlns='urn:xmpp:sm:3' /> cubeInternalUtils.js:116 [Chat] SENT: <a xmlns="urn:xmpp:sm:3" h="7"/> cubeInternalUtils.js:116 [Response][214] {user: {…}} cubeInternalUtils.js:116 [Response][214] {user: {…}} cubeInternalUtils.js:116 [Response][214] {user: {…}} cubeInternalUtils.js:116 [Response][214] {user: {…}} cubeInternalUtils.js:116 [Response][214] {skip: 0, limit: 100, items: Array(100)} cubeInternalUtils.js:116 [Chat] SENT: <iq id="4caa8d7c-137f-429c-8a8f-fbc92de9c333:ping" to="chat.connectycube.com" type="get" xmlns="jabber:client"><ping xmlns="urn:xmpp:ping"/></iq> cubeInternalUtils.js:116 [Chat] RECV: <iq from="chat.connectycube.com" id="4caa8d7c-137f-429c-8a8f-fbc92de9c333:ping" to="3810831-3571@chat.connectycube.com/1206818911-chat-179693" xmlns="jabber:client" type="result"/> cubeInternalUtils.js:116 [Chat] RECV: <r xmlns='urn:xmpp:sm:3' /> cubeInternalUtils.js:116 [Chat] SENT: <a xmlns="urn:xmpp:sm:3" h="8"/>

ccvlad commented 2 years ago

Thanks for ConnectyCube's log.

As I see you send read status to self messages:

[Chat] SENT:
<message
  type="chat"
  from="3810831-3571@chat.connectycube.com/1206818911-chat-179693" // 3810831 - userId who is sending
  to="3810831-3571@chat.connectycube.com" // 3810831 - userId who is receiving
  id="610376678ad533024f000000"
  xmlns="jabber:client">
    <displayed xmlns="urn:xmpp:chat-markers:0" id="6102d09720b3e30028b3c1ae"/>
    <extraParams xmlns="jabber:client">
        <dialog_id>60110656ca8bf470b0aabe34</dialog_id>
    </extraParams>
</message>

Perhaps, I have misunderstood, but you don't need read self messages.