Tris extension

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

Moderators: Lapo, Bax

braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Tris extension

Postby braza » 15 Mar 2014, 12:14

Hi,

I`m reading the Tris example. It fits my needs pretty well, but I`m missing the concept I guess... Could you pelase clarify how is this supposed to work?

- It is not said to select tris as Zone extension, right? I`m expected to put it in the extensions folder and it gets picked up for each room because it was requested by name, right?
- Reading about Zone and Room extensions I was under impression that such turn based room-per-game would be implemented with Room Extension. But that`s no the case, assuming that above assumptions are correct.Is that right too?
- So effectively it would run without any extension set up in the admin page at all on the server, just a JAR in the extensions folder. :shock:
User avatar
Lapo
Site Admin
Posts: 23024
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Tris extension

Postby Lapo » 16 Mar 2014, 14:03

braza wrote:- It is not said to select tris as Zone extension, right? I`m expected to put it in the extensions folder and it gets picked up for each room because it was requested by name, right?

If you check the source code you will notice that the Extension is attached at Room Level. When a new game Room is created the code provides the name of the folder and main class of the Extension so that it can be loaded.

- Reading about Zone and Room extensions I was under impression that such turn based room-per-game would be implemented with Room Extension. But that`s no the case, assuming that above assumptions are correct.Is that right too?

The assumption is not correct.

- So effectively it would run without any extension set up in the admin page at all on the server, just a JAR in the extensions folder. :shock

I don't understand the question, sorry. If my answer is not clear please try to reformulate it.

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Re: Tris extension

Postby braza » 16 Mar 2014, 17:40

Hi, thanks for answering!
Lapo wrote:
braza wrote:- It is not said to select tris as Zone extension, right? I`m expected to put it in the extensions folder and it gets picked up for each room because it was requested by name, right?

If you check the source code you will notice that the Extension is attached at Room Level. When a new game Room is created the code provides the name of the folder and main class of the Extension so that it can be loaded.

I checked the source code of Tris extension, but it isn`t still clear what could give me a hint at which level this extension is attached. I might be not familiar with the API yet, but I did some homework with sources.

Lapo wrote:
- Reading about Zone and Room extensions I was under impression that such turn based room-per-game would be implemented with Room Extension. But that`s no the case, assuming that above assumptions are correct.Is that right too?

The assumption is not correct.

ok. So tris extension is a room extension. This is it.

Lapo wrote:
- So effectively it would run without any extension set up in the admin page at all on the server, just a JAR in the extensions folder. :shock

I don't understand the question, sorry. If my answer is not clear please try to reformulate it.

Thanks

NVM :)
thanks!
User avatar
Lapo
Site Admin
Posts: 23024
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Tris extension

Postby Lapo » 17 Mar 2014, 08:42

braza wrote:I checked the source code of Tris extension, but it isn`t still clear what could give me a hint at which level this extension is attached. I might be not familiar with the API yet, but I did some homework with sources.

If you check the source code (Tris.as) when the player starts a new game a popup window is opened to request the name of the new game Room and a few other details. The OK button in window is handled via this code:

Code: Select all

public function onCreateGamePopuUpBtClick():void
{
   if (createGamePanel.ti_name.length > 0)
   {
      // Create game settings
      var settings:SFSGameSettings = new SFSGameSettings(createGamePanel.ti_name.text);
      settings.groupId = GAME_ROOMS_GROUP_NAME;
      settings.password = createGamePanel.ti_password.text;
      settings.isGame = true;
      settings.maxUsers = 2;
      settings.maxSpectators = createGamePanel.ns_maxSpectators.value;
      
      settings.extension = new RoomExtension(EXTENSION_ID, EXTENSIONS_CLASS);
      
      // Create room
      var request:CreateRoomRequest = new CreateRoomRequest(settings, true, sfs.lastJoinedRoom);
      sfs.send(request);
      
      // Close popup
      removeCreatePopUp();
   }
}


As you can see is the Room settings object is populated with the details of the Extension to use:

Code: Select all

settings.extension = new RoomExtension(EXTENSION_ID, EXTENSIONS_CLASS);

The two constants are defined at the top of the code.

Code: Select all

private const EXTENSION_ID:String = "tris";
private const EXTENSIONS_CLASS:String = "sfs2x.extensions.games.tris.TrisExtension";


Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Re: Tris extension

Postby braza » 20 Mar 2014, 23:05

Thanks again Lapo. I understood that. At the moment I was asking it was actually unclear from the server side, Now I think I get it. There is no server room configured at server at all for tris game except lobby. No static room has it`s room extension set. Jar just being picked up and assigned to a new room right at the moment of request. Before that moment, the room extension isn`t set anywhere on the server and the class library passively exist in the extensions folder.

Should I be receiving SFSEvent.ROOM_ADD or SFSEvent.ROOM_CREATION_ERROR during this room request? Because what I get is only a ROOM_JOIN. According to http://www.smartfoxserver.com/docs/1x/i ... ecture.htm I shouldn`t be, right? But I don`t get it even if do not leave lobby... I do receive ROOM_JOIN though.

It is SFS 2.8.2 and Unity API is I believe 1.5.2.
User avatar
Lapo
Site Admin
Posts: 23024
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Tris extension

Postby Lapo » 21 Mar 2014, 08:29

braza wrote:Should I be receiving SFSEvent.ROOM_ADD or SFSEvent.ROOM_CREATION_ERROR during this room request?.

Yes, that's a good idea.
Lapo

--

gotoAndPlay()

...addicted to flash games
braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Re: Tris extension

Postby braza » 21 Mar 2014, 22:19

Lapo wrote:
braza wrote:Should I be receiving SFSEvent.ROOM_ADD or SFSEvent.ROOM_CREATION_ERROR during this room request?.

Yes, that's a good idea.

I meant that I do subscribe for all of them but never receive ROOM_ADD actually from sfs2x. What could I be missing?
User avatar
Lapo
Site Admin
Posts: 23024
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Tris extension

Postby Lapo » 22 Mar 2014, 09:46

Maybe you are creating the Room in a different group.
Check which groupId is passed to the RoomSettings object when you are creating the Room.
Lapo

--

gotoAndPlay()

...addicted to flash games
braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Re: Tris extension

Postby braza » 22 Mar 2014, 09:47

This part must be in client C# api questions...
braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Re: Tris extension

Postby braza » 22 Mar 2014, 09:48

Lapo wrote:Maybe you are creating the Room in a different group.
Check which groupId is passed to the RoomSettings object when you are creating the Room.

That`s right, it`s another group for 1vs1 games. I`ll investigate docs to find out how to subscribe to other groups then..
User avatar
Lapo
Site Admin
Posts: 23024
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Tris extension

Postby Lapo » 22 Mar 2014, 09:53

You can add the group to the list of "Default Groups" in the Zone configuration, this way you will be subscribed to that group as soon as you login.
Alternatively you can subscribe "on demand" from the client by sending a SubscribeRoomGroupRequest.

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
braza
Posts: 32
Joined: 02 Jan 2014, 21:50

Re: Tris extension

Postby braza » 22 Mar 2014, 10:25

Lapo wrote:You can add the group to the list of "Default Groups" in the Zone configuration, this way you will be subscribed to that group as soon as you login.
Alternatively you can subscribe "on demand" from the client by sending a SubscribeRoomGroupRequest.

cheers

That worked! thank Lapo. I`ve got another theoretical question, I`ll post it client APIs

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 44 guests