Server-side JoinRoom handling
Posted: 22 Jan 2021, 10:44
Hi, a couple of quick questions on the server-side handling of the login and joinRoom process.
1. I have started to pass parameters during login, which I can retrieve using:
ISFSObject params = (ISFSObject) event.getParameter(SFSEventParam.LOGIN_IN_DATA);
but earlier game versions didn't use this. Is there a way to detect whether the parameters are supplied or not? As a workaround, I am wrapping the code in a try, catch block but wanted to know if there's a better way.
2. Is it possible to use roomJoin without triggering the UserJoinedRoomEventHandler? Workaround here is to set a session property during login and skip code here depending on the setting in the session
3. I'm trying to set the permission level during sign-in, using a custom value (say, 8 ). The session.setProperty ("$permission" only allows the default permissions to be set, so I'm using user.setPrivilegeId(short(8)) in the UserJoineZoneHandler instead. Can setPrivilegeId be set during login? Do I need to use both session.setProperty(@$permission and also setPrivilegeID or can I use just one method?
4. The LoginHandler can be stopped using
throw new SFSLoginException("Login failed for user: " + username, data);
and this stops login altogether. I'd like to be able to do the same for the UserJoinedRoomEventHandler as well. I suspect you are already joined when this is triggered, so I can't prevent someone joining a room in this way - for now the workaround is to kick them out if not allowed. Is there a better way to prevent a user from being able to join a room?
Thanks
1. I have started to pass parameters during login, which I can retrieve using:
ISFSObject params = (ISFSObject) event.getParameter(SFSEventParam.LOGIN_IN_DATA);
but earlier game versions didn't use this. Is there a way to detect whether the parameters are supplied or not? As a workaround, I am wrapping the code in a try, catch block but wanted to know if there's a better way.
2. Is it possible to use roomJoin without triggering the UserJoinedRoomEventHandler? Workaround here is to set a session property during login and skip code here depending on the setting in the session
3. I'm trying to set the permission level during sign-in, using a custom value (say, 8 ). The session.setProperty ("$permission" only allows the default permissions to be set, so I'm using user.setPrivilegeId(short(8)) in the UserJoineZoneHandler instead. Can setPrivilegeId be set during login? Do I need to use both session.setProperty(@$permission and also setPrivilegeID or can I use just one method?
4. The LoginHandler can be stopped using
throw new SFSLoginException("Login failed for user: " + username, data);
and this stops login altogether. I'd like to be able to do the same for the UserJoinedRoomEventHandler as well. I suspect you are already joined when this is triggered, so I can't prevent someone joining a room in this way - for now the workaround is to kick them out if not allowed. Is there a better way to prevent a user from being able to join a room?
Thanks