How to detect extension reload

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

Post Reply
LeperMessiah
Posts: 6
Joined: 19 Oct 2011, 07:55
Location: Slovenia
Contact:

How to detect extension reload

Post by LeperMessiah »

Hi all!

Does anybody know how to detect reloading of a room extension in the zone extension? I create several dynamic rooms in my zone extension, each with its own extension. When I reload an extension in Admin Tool, it gets reloaded properly, but my zone extension is not aware of this reload, therefore it doesn't update pointers to extensions.

Searching through documentation I didn't find any event that would be triggered on ext reload. So is there any other way to come around this issue? I was thinking that on room extension init I would obtain pointer to the zone extension and inform it via handleInternalRequest method of this reload. I guess it would work, but is there any other, preferrably "cleaner" method to do this? :)
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

Hello. When an extension is reloaded, there are 2 events that are thrown:

- Destroy event - from the old extension that is being destroyed.
- Init event - from the new extension that is being loaded.

So yes, it looks like the best way to do that is on the extension init, you inform the zone-level one that that extension has inited and replace the old reference.
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.
LeperMessiah
Posts: 6
Joined: 19 Oct 2011, 07:55
Location: Slovenia
Contact:

Post by LeperMessiah »

Thank you for your reply :) Where can I catch these 2 events? In the zone extension's handleInternalEvent method I get no such events. I would assume that I could add event listener on the Room object, but apparently I can't, for there is no addEventListener or similar method. ExtensionHelper also doesn't seem to support adding of event listeners. Also where are constants for those 2 events defined?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Post by rjgtav »

Oh, sorry they aren't common events that you can listen to. Instead, the Init event fires the init function of the extension and the destroy event fires the destroy function.

So you can just override those methods and put there your logic :-)
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.
LeperMessiah
Posts: 6
Joined: 19 Oct 2011, 07:55
Location: Slovenia
Contact:

Post by LeperMessiah »

Oh, ok. Well, I've done it like I've described in my opening post and it seems that it works fine. :)
Post Reply