Room creation

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

Moderators: Lapo, Bax

Devops
Posts: 23
Joined: 27 May 2020, 15:23

Room creation

Postby Devops » 01 Jun 2020, 10:35

Player will be calling a smartfox custom event with a roomId integer. This roomId will keep increasing based on the matchmaking logic outside smartfox and this roomId will change for every new multiplayer match played.

EG: Player will be playing match with roomId 1 and other users will join the roomId 1 until it is full. And if full they will join roomId 2 and so on.

How do we create rooms in smartfox zones for this idea?
If the roomId varies from 1-1000 then do we need to manually create 1000 rooms in smartfox and keep or rooms can be created at runtime based on the roomId(int) passed.
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Room creation

Postby Lapo » 01 Jun 2020, 10:50

Hi,
the numeric ID of a Room is auto-increment, so it's generated by the server.
However you don't necessarily need to base your logic on that numeric ID, you could use the Room's name which you can customize as you want.

Rooms can be created at runtime. So you can search for a Room with an empty player slot and if none is found you can dynamically create a new one with any name. The only limitation with Room names is that there can't be duplicates.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
Devops
Posts: 23
Joined: 27 May 2020, 15:23

Re: Room creation

Postby Devops » 01 Jun 2020, 12:13

Okay.
But I would need a room to be created based on a integer as I have matchmaking logic outside smartfox.

So If I pass 10 as room id and for next room creation if I pass 20 as roomId. Will room with id 10 and 20 be created in smartfox zone?

Also please guide me to some docs where I can undersand more about room creation, room closing, removing player from room and stuffs like that.
Thanks!
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Room creation

Postby Lapo » 01 Jun 2020, 13:48

As I said the Room.getId() property is not under the developer control, that's an auto-increment value, managed by the server.
However this isn't a problem as you can tag Rooms with your own custom Ids.
I mentioned that the Room name could be used to attach a custom Id, imagine calling every Room with "Game-XXX", where XXX is whatever number you want.

If you prefer a cleaner approach use Room properties, via Room.getProperty(key) and Room.setProperty(key, value) and assign whatever ID you need to each created Room.

Makes sense?

Also please guide me to some docs where I can undersand more about room creation, room closing, removing player from room and stuffs like that.

You find all the create/remove methods in the server API, accessible via getApi() in your Extension.
Ex:

Code: Select all

getApi.createRoom(...);
getApi.joinRoom(...);
getApi.removeRoom(...);


Room Basics --> http://docs2x.smartfoxserver.com/Develo ... chitecture
Code Examples --> https://smartfoxserver.com/blog/creatin ... rver-side/
Server API docs -->http://docs2x.smartfoxserver.com/api-docs/javadoc/server/com/smartfoxserver/v2/api/SFSApi.html

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 124 guests