Zone Extension > Room Extension communication

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

Moderators: Lapo, Bax

Post Reply
alex_h
Posts: 15
Joined: 27 Feb 2009, 12:56
Location: Bath, UK

Zone Extension > Room Extension communication

Post by alex_h »

Hi there,

I have created a Zone extension .jar file that handles getting players into a game room and then starting the game once 4 players are present.
I've also made a Game extension .jar file that starts up a scheduled task once the game begins. To do this I need to call a 'startGame' method on the game extension from the Zone extension. I though the best way to do this is probably to use an interface and cast the reference to the rooms extension I receive like this:

IGameRoomExtension roomExt = (IGameRoomExtension)gameRoom.getExtension();

where IGameRoomExtension is an interface with the method 'startGame', but I've run into a problem. I am creating my jar files by right clicking on the package in Eclipse and choosing 'Export'. I have my zone classes in one package, and my room classes in another, so they both get exported to different .jar files. But then the interface needs to be available to both the room and the zone, which means putting it into its own package, and then it doesn't get compiled into either of the jar files.

Can anyone suggest the best way around this problem?
Is there an easier way of calling methods of a room extension from within a zone extension?

thanks,

Alex
alex_h
Posts: 15
Joined: 27 Feb 2009, 12:56
Location: Bath, UK

Post by alex_h »

OK, just found the 'handleInternalMessage' method of BaseSFSExtension - guess this is the answer to my problem!
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

Yup, thats the correct way to do it ;-)
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.
Post Reply