Firing events from different RoomExtensions in the same Zone

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

Moderators: Lapo, Bax

sylhouette
Posts: 20
Joined: 09 Oct 2011, 01:29
Location: Indonesia
Contact:

Firing events from different RoomExtensions in the same Zone

Postby sylhouette » 02 Nov 2011, 05:30

I have two extensions: one for lobby, one for game. The lobby extension is permanent (it is always there, created upon the server startup). The game room extension is created upon the creation of the room itself.

From the lobby, I created a game room using the following code:

Code: Select all

SFSGameSettings settings = new SFSGameSettings("BigTwo Game");
      if (((SfsClient) getApplicationContext()).getSelectedGame().equals(getString(R.string.bigTwo))) {
         settings.setExtension(new RoomExtension(CardGameConstants.bigTwoGameExtensionId, CardGameConstants.bigTwoGameExtensionClass));
         settings.setGame(true);
         settings.setMaxSpectators(4);
         settings.setMaxUsers(4);
         settings.setMinPlayersToStartGame(4);
         settings.setName("testsss");
         settings.setPublic(true);
      }
      sfsClient.send(new LeaveRoomRequest());
      sfsClient.send(new CreateSFSGameRequest(settings));
      finish();
      startActivity(new Intent(RoomActivity.this, BigTwoActivity.class));


Now, I fire a an ExtensionRequest from the game room:

Code: Select all

sfsClient.send(new ExtensionRequest("getPlayerPosition", null));


Here is my stacktrace:
Image

I wonder why the lobby extension gets fired as well? I want the game room extension only to get fired.

The game extension init() method:

Code: Select all

addRequestHandler("getPlayerPosition", GetPlayerPositionHandler.class);
      addEventHandler(SFSEventType.USER_JOIN_ROOM, JoinHandler.class);
      addEventHandler(SFSEventType.USER_LEAVE_ROOM, LeaveHandler.class);


The lobby extension init() method:

Code: Select all

addEventHandler(SFSEventType.USER_LOGIN, LoginHandler.class);


I am using Windows 7 (32bit) and SFS2X RC3 CE.

Thanks a lot for your help :)
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Postby rjgtav » 02 Nov 2011, 06:20

hello. For sending a request to the Room-level extension you need to specify to which room you want to send that extension request. I.m pretty sure in Android the room parameter is the 3rd of the extension request constructor.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
sylhouette
Posts: 20
Joined: 09 Oct 2011, 01:29
Location: Indonesia
Contact:

Postby sylhouette » 02 Nov 2011, 08:00

oh silly me. I thought there was something wrong with my server extension code. I didn't notice there's a third argument in the new ExtensionRequest() constructor. Hope this helps newbies like me >,< Thank you very much for your help :)

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 29 guests