How to set room extension serverside?

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

Moderators: Lapo, Bax

synkarius
Posts: 16
Joined: 02 Oct 2011, 11:36

How to set room extension serverside?

Postby synkarius » 12 May 2012, 00:03

Using 2.0.1., Java.

I was able to set an extension alright using the room.setExtension() command, but then ran into this: viewtopic.php?f=18&t=9758

Following the advice in that topic, I was able to get the Disconnect & Room_Removed events firing, but had trouble with the RoomSettings.setExtension() command. I tried doing it like this: http://code.google.com/p/say-what-you-s ... 6200c96151
--but I got a ClassCastException. All I really need is the proper way to set an extension serverside, in Java.
Last edited by synkarius on 12 May 2012, 17:22, edited 2 times in total.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to set room extension serverside?

Postby Lapo » 12 May 2012, 09:20

Hi,
you need to create a Room using the SFSAPI.createRoom(...) method and passing a CreateRoomSetting object which also contains parameters for creating a Room Extension
Lapo
--
gotoAndPlay()
...addicted to flash games
itsmylifesoham
Posts: 186
Joined: 16 Oct 2011, 14:33

Re: How to set room extension serverside?

Postby itsmylifesoham » 12 May 2012, 09:31

hi,

are you calling the setExtension method on the Room object after it is created?

i dont think you can use that method as it might be internal, as mentioned at many places in the docs that those methods for which no description is provided in the online docs are meant for internal usage.

from what i remember, i have read on many earlier posts than you must set the extension on the room only while creating it by passing the CreateRoomSettings object into the constructor of createRoom method.

I do this server side to create a new room and attach a custom room extension to it:

First a method that outputs my CreateRoomSettings object which can be passed to the creatroom method as shown later :

Code: Select all

private CreateRoomSettings createGameSettings(int cashGameNumPlayers, int cashGameEntryFee)
   {
      CreateRoomSettings waitingRoomSettings = new CreateRoomSettings();      
      
      waitingRoomSettings.setMaxUsers(cashGameNumPlayers);
      waitingRoomSettings.setMaxVariablesAllowed(1);
      waitingRoomSettings.setDynamic(true);
      waitingRoomSettings.setAutoRemoveMode(SFSRoomRemoveMode.WHEN_EMPTY);      
      waitingRoomSettings.setGroupId("cashMultiWaitingGroup");
      waitingRoomSettings.setName(String.valueOf(UUID.randomUUID()));
      
      CreateRoomSettings.RoomExtensionSettings extSettings = new CreateRoomSettings.RoomExtensionSettings("xyz", "xyz.xyz.xyz");
      waitingRoomSettings.setExtension(extSettings);      
      
      RoomVariable gameEntryFee    =    new SFSRoomVariable("gameEntryFee", cashGameEntryFee,false,true,true);        
        List<RoomVariable> roomVariables = Arrays.asList(gameEntryFee);       
        waitingRoomSettings.setRoomVariables(roomVariables);
                                      
        return  waitingRoomSettings;                           
   }


and use above method to create a new room & attach a custom room extension on it server side like so :


Code: Select all

getApi().createRoom(getParentExtension().getParentZone(), createGameSettings(inSFSObject.getInt("cashGameNumPlayers"), inSFSObject.getInt("cashGameEntryFee")), sender, true, null);
synkarius
Posts: 16
Joined: 02 Oct 2011, 11:36

Re: How to set room extension serverside?

Postby synkarius » 12 May 2012, 15:42

Ah, yes, okay. I thought the ClassCastException had to do with how I was setting the extension, but now I see it had to do with something else entirely. Your quick replies helped me confirm this. Thanks for the assist, fellas.

Edit: In case anyone is doing things the same way I am and finds this on Google years later, the ClassCastException I had is explained here: viewtopic.php?t=8788
synkarius
Posts: 16
Joined: 02 Oct 2011, 11:36

Re: How to set room extension serverside?

Postby synkarius » 12 May 2012, 17:26

Wait nevermind. I thought I had it fixed, but now I'm not sure if I'm setting the extension correctly. Lapo, if I understand you correctly in this thread,:
viewtopic.php?t=8788
--- my code ought to look something like this, right?:

Code: Select all

RoomExtensionSettings reSettings = new RoomExtensionSettings("__lib__/", "com.myproject.sfs2x.MyExtension");
settings.setExtension(reSettings);


Also, sorry for the double post. It's just that I'd marked it as resolved before and I wanted to make sure this didn't get overlooked.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to set room extension serverside?

Postby Lapo » 13 May 2012, 09:16

The first parameter is the name of the deployment folder which should be inside the extensions/ folder.
If you deployed your .jar inside extensions/mygame/ the first argument will be --> "mygame"

Deploying the in the __lib__/ is not a good idea.
Lapo

--

gotoAndPlay()

...addicted to flash games
synkarius
Posts: 16
Joined: 02 Oct 2011, 11:36

Re: How to set room extension serverside?

Postby synkarius » 18 May 2012, 15:12

Why is deploying in __lib__ bad? It's what you recommended for this situation in this thread: viewtopic.php?t=8788
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to set room extension serverside?

Postby Lapo » 18 May 2012, 15:29

Well, it wasn't very clear what you were doing.
Lapo

--

gotoAndPlay()

...addicted to flash games
synkarius
Posts: 16
Joined: 02 Oct 2011, 11:36

Re: How to set room extension serverside?

Postby synkarius » 18 May 2012, 15:35

Ah. My mistake. Sorry about that. I'll try to be clearer next time.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: How to set room extension serverside?

Postby Lapo » 18 May 2012, 15:38

np :)
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Stevenor and 114 guests