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.
How to set room extension serverside?
How to set room extension serverside?
Last edited by synkarius on 12 May 2012, 17:22, edited 2 times in total.
Re: How to set room extension serverside?
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
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
-
- Posts: 186
- Joined: 16 Oct 2011, 14:33
Re: How to set room extension serverside?
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 :
and use above method to create a new room & attach a custom room extension on it server side like so :
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);
Re: How to set room extension serverside?
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
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
Re: How to set room extension serverside?
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?:
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.
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.
Re: How to set room extension serverside?
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.
If you deployed your .jar inside extensions/mygame/ the first argument will be --> "mygame"
Deploying the in the __lib__/ is not a good idea.
Re: How to set room extension serverside?
Why is deploying in __lib__ bad? It's what you recommended for this situation in this thread: viewtopic.php?t=8788
Re: How to set room extension serverside?
Well, it wasn't very clear what you were doing.
Re: How to set room extension serverside?
Ah. My mistake. Sorry about that. I'll try to be clearer next time.
Who is online
Users browsing this forum: Stevenor and 114 guests