Description
I am experiencing some issue when I call the ssClient.openSubsessions() function. The issue is that the users in the unassignedUserList never get reassigned to another subsession. So I tried to get the unassignedUserList and and iterate over the list and called the assignUserToSubsession(userId, subsessionId) function below.
const openSubsessions = useCallback(async () => {
if (ssClient) {
ssClient.openSubsessions(subsessions, options);
setSubsessionStatus(SubsessionStatus.InProgress);
console.log('sub status', subsessionStatus);
console.log('ssclient stat', ssClient.getSubsessionStatus());
await assignUnassignedUsersToAnyRunningSubsessions();
}
}, [ssClient, subsessions, options, subsessionStatus, assignUnassignedUsersToAnyRunningSubsessions]);`
const assignUnassignedUsersToAnyRunningSubsessions = useCallback(() => {
console.log(‘not in any sub sessions’, unassignedUserList);
console.log(‘available subsessions’, ssClient?.getSubsessionList());
setSubsessionStatus(SubsessionStatus.InProgress);
if(ssClient) {
if(unassignedUserList.length && ssClient.getSubsessionList().length) {
const availableSubSessions = ssClient.getSubsessionList();
unassignedUserList.forEach((user) => {
const targetSubSession = Math.floor(Math.random() * availableSubSessions.length);
const targetSubsessionId = availableSubSessions[targetSubSession].subsessionId;
console.log('target sub', targetSubSession);
console.log('target sub sub', availableSubSessions[targetSubSession]);
assignUserToSubsession(
user.userId,
targetSubsessionId,
user.displayName,
);
});
}
}
}, [unassignedUserList, ssClient, assignUserToSubsession]);`
const assignUserToSubsession = useCallback(
(userId: number, subsessionId: string, displayName: string, avatar?: string) => {
console.log(‘sub status’, subsessionStatus);
if (subsessionStatus === SubsessionStatus.InProgress) {
if (ssClient) {
ssClient.assignUserToSubsession(userId, subsessionId);
console.log('passed, supposed success');
}
}
setSubsessions(
produce((subsessions: Subsession[]) => {
const subsession = subsessions.find((r: Subsession) => r.subsessionId === subsessionId);
if (subsession) {
subsession.userList.push({
userId,
displayName,
avatar,
isInSubsession: false
});
}
})
);
},
[ssClient, subsessionStatus]
);`
But when I call the assignUserToSubsession, it doesn’t run the block below within the function. From the console logs which I had put within the assignUnassignedUsersToAnyRunningSubsessions function it showed that the subsessionStatus was not equal to SubsessionStatus.InProgress, even when I changed the state within the assignUnassignedUsersToAnyRunningSubsessions function.
if (subsessionStatus === SubsessionStatus.InProgress) { if (ssClient) { ssClient.assignUserToSubsession(userId, subsessionId); console.log('passed, supposed success'); } }
If I try to silence the check in the block above in order to let the sscClient.assignUserToSubsession
function run by all means, it returns an INTERNAL ERROR
with no message.
This is not a good behaviour for us and I hope you can help me resolve it. Our project is already beyond deadline and it seems we only keep running into these issues.