Chats lost when I switch from main session to subsession or from subsession to main session

Video SDK Type and Version
Web Video SDK version: 1.5.5

Description
When I switch from main session to subsession or from subsession to main session the chat records are lost.

Hi @godwin.owonam ,

How are you storing and displaying chat messages in your application?

Thanks,
Rehema

Hello @rehema.zoom,
Thanks for responding. Currently on the Zoom Video SDK, (being that I have not changed the functionality), the chats are stored in the chat records which are stately preserved (in react useState hook) as an array.

The issue here is that these chat records are lost because the parent component (component which the Chat component is rendered) is re-rendered when I switch between main session and sub-session.

Like I said, I haven’t changed this functionality, so I’m wondering if there’s a way the SDK can be made to preserve the messages.

Hey @godwin.owonam

The chat records will not be preserved when you are in and out of the subsession. The reason for this is that the userId will be changed after returning back to the main session from the subsession, which may cause the chat records to be inconsistent.

For your case, a workaround is to use an independent store (such as Redux, Mobx, or React Context, etc) to preserve the records within your application.

Thanks
Vic

Thanks @vic.yang

I will try the options you listed, but is the fact that the userId changes when retaining to the main session, the intended behaviour? Is there no way that the Devs can work around to keep this fixed?

I will keep you updated if any of the options you gave solved the issues.
Best regards.
@godwin.owonam

@vic.yang

I used React Context and it did preserve the messages from the main room to the sub-sessions.

In my current implementation I used the React context to store the chat records, but it seems this record is not maintained between the main and sub-sessions. Feels like a temporary disconnect between the two instances. I have attached code snippets of the implementation below.

And this is a bigger issue for us when messages sent from the main room cannot be seen by participants in the sub-sessions.

That is, if the participants are in the sub sessions, and the host is in the main session, the chat message sent by the host in the main session is not visible to the participants in the sub sessions.

I would really appreciate your help.

In chat-record-context.ts

import React from 'react';
export default React.createContext<any | null>([]);

In App.tsx

 const [chatRecords, setChatRecords] = useState<ChatRecord[]>([]);

<ChatRecordContext.Provider value={{chatRecords, setChatRecords}}>
   // ...  router logic with all components within
</ChatRecordContext.Provider>

In chat.tsx:

const {chatRecords, setChatRecords} = useContext(ChatRecordContext);
  // const [chatRecords, setChatRecords] = useState<ChatRecord[]>([]); (Previous storage)

Hey @godwin.owonam

It seems there are two concerns regarding the chat function:

  • In order to ensure seamless connectivity between users in the main session and subsession, we have implemented the userGuid attribute in the participant payload. This attribute remains unchanged throughout the entire session, regardless of how many times a user enters or leaves the subsession.
    Participant | Zoom Video SDK for Web - 1.9.5

  • To send messages to the subsession, you can use the subsession.broadcast method. However, please keep in mind that only the host role can use this method, and the message will be broadcasted to all subsessions and the main session.
    SubsessionClient | Zoom Video SDK for Web - 1.9.5

Thanks
Vic

Thanks @vic.yang

So you’re saying I should upgrade the SDK? Would this be all I need to do?

Because I stated that I am using 1.5.5 in my first post.

In order to ensure seamless connectivity between users in the main session and subsession, we have implemented the userGuid attribute in the participant payload. This attribute remains unchanged throughout the entire session, regardless of how many times a user enters or leaves the subsession.
Participant | Zoom Video SDK for Web - 1.9.5

Does this mean that messages in the main session chat will be seen in the subsession chat. Because that is what we want ATM. @vic.yang

Hey @godwin.owonam

It’s better to upgrade to the latest Video SDK Web version(1.9.5).

The userGuid attribute has been available since Video SDK 1.6.0.

If you need to send the message from the main session, use subsession.broadcast method. Please see the second point of the above comment.

To send messages to the subsession, you can use the subsession.broadcast method. However, please keep in mind that only the host role can use this method, and the message will be broadcasted to all subsessions and the main session.

Thanks
Vic

Hi @vic.yang

So I upgraded the SDK as you said, but that doesn’t solve the problem because even though the userGuid is currently in the latest SDK, it is not used for the chats functionality, hence the problem was not solved even when userGuid was introduced in the SDK.

Unless I am supposed to do any extra work with the userGuid to solve this, upgrading did not solve this issue.

Hey @godwin.owonam

That’s correct. Currently, userId is still used in the API of Video SDK Web.

In order to associate the chat records of the main session with the user, we need to first use the userId to identify the user and then retrieve the corresponding userGuid. As I mentioned before, the userGuid remains unchanged throughout the session, allowing us to establish a connection between the chat records from the main session and other subsessions.

Thanks
Vic

Hi @vic.yang

Do you mean this is something I have to do or is already done?

Hey @godwin.owonam

In order to associate the chat records of the main session with the user, we need to first use the userId to identify the user and then retrieve the corresponding userGuid . As I mentioned before, the userGuid remains unchanged throughout the session, allowing us to establish a connection between the chat records from the main session and other subsessions.

That’s what you need to do in your application.

Thanks
Vic