Page 1 of 1

How to detect extension reload

Posted: 08 Nov 2011, 10:51
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? :)

Posted: 08 Nov 2011, 19:31
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.

Posted: 09 Nov 2011, 08:56
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?

Posted: 09 Nov 2011, 23:13
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 :-)

Posted: 10 Nov 2011, 07:28
by LeperMessiah
Oh, ok. Well, I've done it like I've described in my opening post and it seems that it works fine. :)