Check if user is active upon session close

Hi, I understand that upon user deactivation, onSessionClosed event handler will be triggered. However, as there’s no extra value being passed in from the event handler, how can we determine if onSessionClosed is being triggered due to user deactivation?

I tried using Sendbird SDK’s currentUser.isActive, but apparently upon session close, currentUser is emptied into null value.

Hey @GabrielLim_ML,

Which version of the Javascript SDK are you utilizing? I will need to take a look but need to know which version to take a look at.

Sorry, forgot to mention, it is v3

Hi @Tyler , did you manage to find anything? :cold_face:

@Tyler or can you let me know what are some possible scenarios that will cause a session to be closed except user deactivation? It’s not stated in the documentation

Hello @GabrielLim_ML,

Apologies for the delayed response. It’s been a very busy week. When a user is deactivated, our server sends a message across any open websocket connections the user has. This message purely tells the SDK that the session has expired. It provides no other information. For that reason, you can’t explicitly know why the session disconnected.

Typically onSessionClosed will only fire when the backend server explicitly closes the connection. This would occur on deactivation or when tokens expire. What you could do is attempt to reconnect when onSessionClosed occurs, and the error from the .connect() would tell you the user has been deactivated.

1 Like