Cast to an specific room extension from a zone 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

votagusvotag
Posts: 38
Joined: 07 Nov 2016, 12:26

Cast to an specific room extension from a zone extension

Postby votagusvotag » 17 Jan 2017, 20:30

Hi, this is a question that I have been wondering for a while now.
I have one zone extension and three room extensions, and they are all in diferent projects, now let's supose that I have to do some tasks when a disconnect event occur, since disconnect is a zone level event, I can catch the event, and I can get the rooms of the user and tell the kind of room based on variables, etc. But how should I do if I want to call a method that exist in that room extension? I can't cast to it because I don't have any reference to the class in the zone extension project.
Can I put a copy of the room extension in the project of the zone extension, and expect the cast to work? Would that duplicate the class when I generate the .jar files?

I know that there is a __lib__ folder but I think is not for extension classes.

What are your suggestions? Thanks!
User avatar
Lapo
Site Admin
Posts: 23027
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Cast to an specific room extension from a zone extension

Postby Lapo » 18 Jan 2017, 07:30

Hi,
...since disconnect is a zone level event

DISCONNECT is dispatched to both Zone and Room extensions, not just at Zone level.

I know that there is a __lib__ folder but I think is not for extension classes.

Yes, you can use it for Extensions as well, and it will load all of your Extension classes in the same classloader avoiding errors when you cast from one Extension to another.

More on this here:
http://docs2x.smartfoxserver.com/Advanc ... assLoading

cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
votagusvotag
Posts: 38
Joined: 07 Nov 2016, 12:26

Re: Cast to an specific room extension from a zone extension

Postby votagusvotag » 18 Jan 2017, 13:20

Hi, I was convinced that in one post you said that handle the DISCONNECT event at room level was a tricky task and would be removed in future releases, I can't find the post and I just can assume you were talking about other event.
I think I'll choose the first option and implement the event at room level. Thanks!

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 111 guests