[Client Side] Subscribe room group and get all room list

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

tinnt
Posts: 38
Joined: 22 May 2012, 06:59

[Client Side] Subscribe room group and get all room list

Postby tinnt » 22 Nov 2012, 07:03

Hi everyone,

I developed an extension on server side and listen to SERVER_READY then create rooms for the first time as the following:

Code: Select all

                CreateSFSGameSettings gameSettings = new CreateSFSGameSettings();
      gameSettings.setGroupId("abc");
      if (password != null && !password.trim().isEmpty()) {
         gameSettings.setPassword(password);
      }
      gameSettings.setName(name);
      gameSettings.setMinPlayersToStartGame(2);
      gameSettings.setGamePublic(true);
      // create game extension
      RoomExtensionSettings extension = new RoomExtensionSettings(zoneExtension.getGameExtensionID(), zoneExtension.getGameExtensionClassName());
      gameSettings.setExtension(extension);
      // create room variable list
      
      // create game
      ISFSGameApi gameApi = SmartFoxServer.getInstance().getAPIManager().getGameApi();
      try {
         gameApi.createGame(zoneExtension.getParentZone(), gameSettings, null, true, false);
      } catch (SFSCreateRoomException e) {
         e.printStackTrace();
      }


From client side I connect to server and check to subscribe to a room group but I get the erro message "Group abc does not exist".

Code: Select all

        // Check if the "game" group is already subscribed; if not, subscribe it
   if (!sfsClient.getRoomManager().containsGroup("abc"))
   {
      sfsClient.send(new SubscribeRoomGroupRequest("abc"));
   }


From the admin tool I can see all the groups and rooms have been created before.

How can I subscribe and get room list created by server?

Thanks,
Tin.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: [Client Side] Subscribe room group and get all room list

Postby Lapo » 22 Nov 2012, 10:07

The group name should exist also in the Public Room Groups field that you find in the AdminTool > ZoneConfigurator.
Groups that are not defined as public are not accessible from client side (they are from server side)

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
tinnt
Posts: 38
Joined: 22 May 2012, 06:59

Re: [Client Side] Subscribe room group and get all room list

Postby tinnt » 22 Nov 2012, 10:29

Got it, thanks for your help.

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 12 guests