Change Room Name on server properly

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

User avatar
pogsdbest
Posts: 17
Joined: 08 Feb 2019, 10:09

Change Room Name on server properly

Postby pogsdbest » 14 Feb 2019, 19:22

Hi i want to ask how to properly change the name on a Room that was created by the Client.

Code: Select all

RoomSettings settings = new RoomSettings ( "Table" );


On my room extension after the client created a room i call

Code: Select all

 @Override
    public void init() {
       Room room = getParentRoom();
       room.setName(room.getName()+room.getId()); //i add the generated id for monitoring purpose
    }

take note that i enabled room settings permission AllowNameChange = true

the room name is changed on my client and also on the SmartFox Zone Monitor but the problem is.
whenever i create room again with the RoomSettings ( "Table" ) the server throws an Error

Room creation error. A room with the same name already exists: Table


even i've changed the first created Room name to Table+id
User avatar
pogsdbest
Posts: 17
Joined: 08 Feb 2019, 10:09

Re: Change Room Name on server properly

Postby pogsdbest » 14 Feb 2019, 19:36

sorry after reading some old comments here's the answer to my question

Code: Select all

   Room room = getParentRoom();
       try {
      getApi().changeRoomName(null, room, room.getName()+"-"+room.getId());
   } catch (SFSRoomException e) {   
      e.printStackTrace();
   }
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Change Room Name on server properly

Postby Lapo » 15 Feb 2019, 15:33

Yes, that's correct. Calling Room.setName() will only change the name locally with no updates for the clients.
You must always use the main SFSApi class to find methods that trigger those updates.

See here for more: http://docs2x.smartfoxserver.com/Extens ... ension-api
Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 27 guests