Zone extension vs Room 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

meralan
Posts: 1
Joined: 26 Oct 2011, 19:37
Location: United States

Zone extension vs Room extension

Postby meralan » 26 Oct 2011, 19:51

Hi everybody,

I configure my Zone with an extension although it's initialized I got an error when I try to send a request to server as :
26 Oct 2011 12:10:03,760 WARN [com.smartfoxserver.v2.controllers.ExtensionController-1] v2.controllers.ExtensionController -
com.smartfoxserver.v2.exceptions.SFSExtensionException: No extensions can be invoked: { Zone: SimpleChat }, RoomId: 1
com.smartfoxserver.v2.controllers.ExtensionController.processRequest(ExtensionController.java:120)
com.smartfoxserver.bitswarm.controllers.AbstractController.run(AbstractController.java:96)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
java.lang.Thread.run(Thread.java:680)


Interesting point for me is that when I configure the room I am connecting to with the same extension I got no errors and extension works fine.

Here is my objective-c client code :

Code: Select all

smartFox = [[SmartFoxiPhoneClient alloc] initSmartFoxWithDebugMode:YES delegate:self];
[smartFox loadConfig:@"config.xml" connectOnSuccess:YES];


config.xml :
<SmartFoxConfig>
<ip>192.168.51.168</ip>
<port>9933</port>
<blueBoxIpAddress>192.168.51.168</blueBoxIpAddress>
<blueBoxPort>8080</blueBoxPort>
<smartConnect>true</smartConnect>
<httpPort>8080</httpPort>
<httpPollSpeed>750</httpPollSpeed>
<zone>SimpleChat</zone>
</SmartFoxConfig>


Code: Select all


-(void)onConnection:(SFSEvent *)evt
{
   if ([[evt.params objectForKey:@"success"] boolValue]) {
        [smartFox send:[LoginRequest requestWithUserName:@"username" password:@"" zoneName:@"SimpleChat" params:nil]];
   }
   else {   
      NSLog(@"Error in establishing connection!");   
   }
}



Code: Select all

-(void)onLogin:(SFSEvent *)evt {
   [smartFox send:[JoinRoomRequest requestWithId:@"The Lobby"]];
}


I thought Rooms can use the Zone extension without problem. Does anybody experience anything like this?

BTW, I am using SFS2X 2.0.0-RC3.

Thanks in advance
User avatar
Bax
Site Admin
Posts: 4490
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 26 Oct 2011, 21:25

Zone and Rooms don't share Extensions. For the Zone, you have to assign an Extension in the AdminTool's Zone Configurator - Zone details.
For Rooms you have to assign an Extension when creating the Room at runtime (or assign it in the AdminTool's Zone Configurator - Room details for static rooms).
Paolo Bax
The SmartFoxServer Team
Robbilie
Posts: 190
Joined: 04 Sep 2010, 19:48
Location: Ratingen, Germany
Contact:

Postby Robbilie » 27 Oct 2011, 06:56

but you can let your zone extension control your room(extension)s

But this also requires both, zone and room extension...
User avatar
Bax
Site Admin
Posts: 4490
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 29 Oct 2011, 04:46

Zones and Rooms can have Extensions at the same time, but they must be separate classes, not the same one.
Paolo Bax
The SmartFoxServer Team
wzp002
Posts: 14
Joined: 26 Mar 2013, 09:29

Re: Zone extension vs Room extension

Postby wzp002 » 02 Aug 2013, 08:57

Hi, is there any way to access the zone extension from a room extension?
User avatar
Lapo
Site Admin
Posts: 21287
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Zone extension vs Room extension

Postby Lapo » 02 Aug 2013, 09:31

Sure.
From the RoomExtension:

Code: Select all

SFSExtension myExt = getParentRoom().getZone().getExtension()
Lapo
--
gotoAndPlay()
...addicted to flash games
wzp002
Posts: 14
Joined: 26 Mar 2013, 09:29

Re: Zone extension vs Room extension

Postby wzp002 » 02 Aug 2013, 17:53

thanks for your suggestion.

I followed this way but caused a ClassCastException.
User avatar
Lapo
Site Admin
Posts: 21287
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Zone extension vs Room extension

Postby Lapo » 02 Aug 2013, 18:37

You should probably deploy your Extension under the extensions/__lib__/ folder to avoid the problem.
The reason is explained in details here:
http://docs2x.smartfoxserver.com/Advanc ... assLoading
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Aldenea, DavinVicy, DerikFent, Google [Bot], JerodSa and 11 guests