I have a use case where I'd like to join a user to a room (B) if he joined room (A) and specific conditions were met
So the scenario is:
1. User is in any room (X)
2. User send request to join room (A)
3. User is joined to room (A)
4. If condition is satisfied, join user to room (B)
I listen to USER_JOIN_ROOM event on room (A) extension
Code: Select all
addEventHandler(SFSEventType.USER_JOIN_ROOM, UserJoinedRoomEventHandler())
Code: Select all
class UserJoinedTournamentRoomEventHandler : BaseServerEventHandler() {
override fun handleServerEvent(event: ISFSEvent) {
val user = event.getParameter(SFSEventParam.USER) as User
if (conditionIsMet(user))
JoinRoomB(user)
}
// More code omitted for simplicity ...
}
But sometimes exception "SFSRuntimeException: Join request discarded. User is already in a join transaction" is thrown
I suspect that when server event is fired, user is still joining.
I can schedule JoinRoomB() to happen after a delay but that seems more of a hack and less of a solution
Is there a proper way to listen to USER_JOIN_ROOM then wait for user to finish joining then call another join room?