How do you remove a room password at run-time?

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

AdmiralSnackbar
Posts: 3
Joined: 03 Sep 2019, 19:41

How do you remove a room password at run-time?

Postby AdmiralSnackbar » 03 Sep 2019, 19:47

Hi everyone, I'm new to these forums and have recently been learning/using SmartFox. I have a current task to add/remove a password at run-time. Setting a password is straight forward and simple, however I can't seem to remove the password when necessary. In the documentation I am only seeing a set and a get for a password. I have tried setting the password to null and to an empty string, but that doesn't remove the requirement of the password. I think I'm missing something but not sure what it is. Any help or direction would be greatly appreciated, thank you!
User avatar
Lapo
Site Admin
Posts: 20959
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How do you remove a room password at run-time?

Postby Lapo » 04 Sep 2019, 06:44

Hi,
once a Room has been create with a password it should stay like that. In other words a password-protected Room is private, and therefore it should only be joined by players knowing the password.

Removing the password would mean that all of a sudden the Room is no longer private, so why bothering making it private in the first place?

In any case if you want to change the "private" state you can still do it from server side. Like this:

Code: Select all

roomObject.setPassword(null);

This will unlock the Room for everyone to join, though it won't send any updates on the client side. So on their side they will still see the Room as private, if you check the relevant flag. In any case clients will be able to join the Room anyways.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
AdmiralSnackbar
Posts: 3
Joined: 03 Sep 2019, 19:41

Re: How do you remove a room password at run-time?

Postby AdmiralSnackbar » 04 Sep 2019, 15:03

Thank you for the response Lapo. To answer your question it's a online space that admins will want to reserve once in a while and once they're done to re-open the room for others. I have tried setting the password to null already but it didn't seem to remove the requirement, or as you said the client may not have been updated that the server is no longer private. So if that is the case, what flag do I need to update and inform the client about and how do I send that?
User avatar
Lapo
Site Admin
Posts: 20959
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How do you remove a room password at run-time?

Postby Lapo » 05 Sep 2019, 09:59

Hi,
for this kind of scenario I would probably use a different strategy.
I would leave the Room public for everyone to join when it is "open". When Admins want to close the Room, you can lock the it via

Code: Select all

room.setActive(false)

People still inside will not be affected but other Users won't be able to join, until the flag is put back to true.

Would this work for you?
Lapo

--

gotoAndPlay()

...addicted to flash games
AdmiralSnackbar
Posts: 3
Joined: 03 Sep 2019, 19:41

Re: How do you remove a room password at run-time?

Postby AdmiralSnackbar » 11 Sep 2019, 16:22

Sorry for the late response I was on vacation. No, unfortunately I don't think that would work in the case I was given. This is basically a virtual office and I can't guarantee that everyone will already be in the room by the time it is locked.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 19 guests