Changing room owner

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

Moderators: Lapo, Bax

Noob666
Posts: 4
Joined: 11 Apr 2019, 15:23

Changing room owner

Postby Noob666 » 11 Apr 2019, 15:30

Hello,

sorry for stupid question but can I change room owner like this?

Code: Select all

        User bot1 = getApi().createNPC("MyBot1", getParentExtension().getParentZone(), true);
        User bot2 = getApi().createNPC("MyBot2", getParentExtension().getParentZone(), true);

        CreateRoomSettings cfg = new CreateRoomSettings();

        cfg.setName("MyNewRoom ");
        cfg.setMaxUsers(50);
        cfg.setDynamic(true);

        try
        {
             Room myNewRoom = getApi().createRoom(getParentExtension().getParentZone(), cfg, bot1);
             myNewRoom.setOwner(bot2);
        }
        catch (SFSCreateRoomException exc)
        {
              //catch error
        }

User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Changing room owner

Postby Lapo » 11 Apr 2019, 16:24

Hi,
good question. I would not recommend doing that. Rooms are not supposed to change owner at runtime, they should be owned by the right User the moment they are created.

In your example where you're changing the ownership one line after having created the Room and assigned it another User (or NPC). Can't you just assign the correct ownership at creation time?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
Noob666
Posts: 4
Joined: 11 Apr 2019, 15:23

Re: Changing room owner

Postby Noob666 » 12 Apr 2019, 08:33

Hmmmm. So it seems, that Smartfox is suitable for games like Tic-tac-toe, Tetris or Chess. So games, where games are relatively short and creator of the game is connected until game end. But it is not very usable for games, that take longer time and creator could delegate ownership to someone else. So for game like Counter-Strike (where creator could leave inside game), we should use something different?

Thanks mate for clarification!
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Changing room owner

Postby Lapo » 12 Apr 2019, 10:58

No, your conclusion is not correct.
Rooms can exist for as long as you want. In fact you can assign the Server itself as the owner of a Room and the Room will exist as long as the server runs or as long as you decide to remove it.

Makes sense?

The only "limitation", which shouldn't really affect any particular game is that Room ownership is decide at the time of creation and it doesn't change later.
I can't think of a use case where changing ownership would that critical, but maybe you can suggest something.
If so I'd like to hear about it.

Finally, Room ownership in SFS2X is only important if you want Rooms to be managed automatically, but you can always override it and decide the life cycle of each Room, via server side code.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Noob666
Posts: 4
Joined: 11 Apr 2019, 15:23

Re: Changing room owner

Postby Noob666 » 12 Apr 2019, 11:43

So you think almost nobody would need change owner inside lifetime of the room and so it is ok? And if yes, they must implement it by themself? Very interesting sight... What other features must be reimplemented, because in SFS exists but cannot be used? Have you somewhere list of them?

We need product, which will help us in maximal amount of features, so we can concentrate on game logic and not product that will force us every single feature reimplement by ourself. Such product is useless for us, sorry. You will be happy, if you buy car and you will uncover, that you cannot use built-in rear-view mirror and you must manufacture your own? Me not.

Thank you.
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Changing room owner

Postby Lapo » 12 Apr 2019, 16:01

Noob666 wrote:So you think almost nobody would need change owner inside lifetime of the room and so it is ok?

Well, this is the first time it's been asked. In 8 years.
Can you explain why it is important? This way we can see how we can help.

What other features must be reimplemented

I don't understand your question. I did not say that you have to re-implement anything.
What I said is that SmartFoxServer comes with a default Room management system which implements a few basic rules, which can be learned here.
http://docs2x.smartfoxserver.com/Develo ... chitecture

If those rules don't suit your game logic you can simply bypass the automatic management, and decide when Rooms should be removed via server side coding.

We need product, which will help us in maximal amount of features, so we can concentrate on game logic and not product that will force us every single feature reimplement by ourself.

Room management is actually part of the game logic, since your game rules dictate how Rooms will be created and destroyed.
We provide an all-purpose Room management that covers some of the basic usages, but we can't cover every single possibility. In addition we provide high level API that allow you to control the creation and destruction of said Rooms.

Such product is useless for us, sorry. You will be happy, if you buy car and you will uncover, that you cannot use built-in rear-view mirror and you must manufacture your own? Me not.

I think there's a gross misunderstanding here, and I've explained why.
This is not a case of a rear-view mirror not working. We provide a rear-view mirror that behaves exactly as you'd expect in 90% of the use cases. Still, if your use case is not covered you're given high level API to control the mirror and customize it's behavior with very few lines of code.

Also it's not clear why you're immediately jumping to rash conclusions, when you haven't even explained what kind of use case you're working on.

We're here to help, if you let us :)
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Changing room owner

Postby Lapo » 12 Apr 2019, 18:57

Lapo wrote:
Noob666 wrote:So you think almost nobody would need change owner inside lifetime of the room and so it is ok?

Well, this is the first time it's been asked. In 8 years.
Can you explain why it is important? This way we can see how we can help.

What other features must be reimplemented

I don't understand your question. I did not say that you have to re-implement anything.
What I said is that SmartFoxServer comes with a default Room management system which implements a few basic rules, which can be learned here.
http://docs2x.smartfoxserver.com/Develo ... chitecture

If those rules don't suit your game logic you can simply bypass the automatic management, and decide when Rooms should be removed via server side coding.

We need product, which will help us in maximal amount of features, so we can concentrate on game logic and not product that will force us every single feature reimplement by ourself.

Room management is actually part of the game logic, since your game rules dictate how Rooms will be created and destroyed.
We provide an all-purpose Room management that covers some of the basic usages, but we can't cover every single possibility. In addition we provide high level API that allow you to control the creation and destruction of said Rooms.

Such product is useless for us, sorry. You will be happy, if you buy car and you will uncover, that you cannot use built-in rear-view mirror and you must manufacture your own? Me not.

I think there's a misunderstanding here, and I've explained why.
This is not a case of a rear-view mirror not working. We provide a rear-view mirror that behaves exactly as you'd expect in 90% of the use cases. Still, if your use case is not covered you're given high level API to control the mirror and customize it's behavior with very few lines of code.

Also it's not clear why you're immediately jumping to rash conclusions, when you haven't even explained what kind of use case you're working on.

We're here to help, if you let us :)
Lapo

--

gotoAndPlay()

...addicted to flash games
Noob666
Posts: 4
Joined: 11 Apr 2019, 15:23

Re: Changing room owner

Postby Noob666 » 16 Apr 2019, 17:49

Lapo wrote:Well, this is the first time it's been asked. In 8 years.

Please remember, 8 years is not too much to learn something new. Or do you think you know already everything? Quick search in this forum gives me hint, that you have already listened about it and you only forgot it:
viewtopic.php?f=18&t=12759&p=52152
viewtopic.php?f=4&t=5092&p=21139

Lapo wrote:Can you explain why it is important? This way we can see how we can help.

I though I already explained it. But I can try it again if you didn't get it. There are games (for example Counter-strike or our game), in which some person creates game (or room if you want). This only person has permission to add or remove other players. Games can took long time, so the owner is not able to play all rounds. So if he leaves game he need to choose new owner so someone could be able to manage player list. Did you get it already? You didn't hear it already because you probably don't play games at all or I don't know...

Lapo wrote:I think there's a misunderstanding here, and I've explained why.


Yes, there is a big misunderstanding by you and I will try it explain it again:
I will buy car with rear-view mirror and I suppose that mirror is there because of looking behind the car. This is not mentioned in manual because it is well-known fact. And 90% people will use it for looking behind the car.
And now imagine I would buy some game multiplayer software with room management. There is a public method named "setOwner" inside the Room class. What could be purpose of this method? Because it is not well documented, I could only assume its purpose and I think (and 90% other developers will do probably the same) it is for changing owner. Or do you think it could have another purpose? It could, but it does not make much sense. So please show me the right purpose of this method. I am very curious.

So I think analogy with car's rear-view mirror is perfect match. And now you are saying don't change owner, because it is bad. And it this the same as you would say don't use that builtin rear-view mirror in our car, it is bad and don't use it (which is stupid, because driver needs it) or make it rather yourself (which I think it's stupid too).

If you still don't understand please try to read it several times and think about it before posting replies, which are having low information value.

Thank you.
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Changing room owner

Postby Lapo » 17 Apr 2019, 09:33

I think a less condescending tone would help the discussion, but that's just me :)

Room objects support custom properties. You can attach any value via getProperty()/setProperty()
So it doesn't take much coding (namely one line) to store the owner of the game in those properties and then apply your game logic as necessary.

In terms of SmartFoxServer you just set the Room.owner property to null, so that you can handle the lifecycle of the Room as you see fit. Which is what your game requires anyways, as per your description.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
Jochanan
Posts: 79
Joined: 11 May 2018, 09:12

Re: Changing room owner

Postby Jochanan » 17 Apr 2019, 09:40

I am just being curious here, but what is the purpose of the public method named "setOwner" inside the Room class if not changing the owner?
I have read a pages of text here, but no answer to be found.
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Changing room owner

Postby Lapo » 17 Apr 2019, 10:10

Jochanan wrote:I am just being curious here, but what is the purpose of the public method named "setOwner" inside the Room class if not changing the owner?

To set the owner ;) At Room creation time.

As per our docs, methods that are not documented in the javadocs are for internal use only.
The day that the javadoc tool will support a way to hide methods, we'll remove them.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
Jochanan
Posts: 79
Joined: 11 May 2018, 09:12

Re: Changing room owner

Postby Jochanan » 17 Apr 2019, 10:43

Lapo wrote:
Jochanan wrote:I am just being curious here, but what is the purpose of the public method named "setOwner" inside the Room class if not changing the owner?

...
As per our docs, methods that are not documented in the javadocs are for internal use only.
...

Do you know, that java has a keyword called private? How can anyone expect, that public function is not for public usage?
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Changing room owner

Postby Lapo » 17 Apr 2019, 10:55

@Jochanan
You should stop trolling this forum. One more post like this and you're out.
Thank you.
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 58 guests