oops, this hack was to quick ;o)
this one should works:
var ChannelReg = (function(){
var events = {}; this.addOnJoin = function (channel,
callback){ if(!events['join']){ events['join'] =
{}; Ape.addEvent('join'), function(user, channel) {
if
(events['join'][channel.getProperty('name')]) {
events['join'][channel.getProperty('name')].call(NULL, user, channel);
} } }
events['join'][channel.getProperty('name')] = callback;
}
this.removeOnJoin = function (channel, callback){
events['join'][channel.getProperty('name')] = false; }
})();
--- Timo Michna <[email protected]> schrieb am Mo, 15.3.2010:
Von: Timo Michna <[email protected]>
Betreff: AW: [APE Project] Re: 1) [SSJS] pipe.onSend callback never called. 2)
[SSJS] are 'join' and 'left' events for one specific channel ?
An: [email protected]
Datum: Montag, 15. März, 2010 19:30 Uhr
Hi!
For 1):What I meant is, that maybe the event is not fired on the channel´s
pipebut only on the user´s pipe, so that´s why you callback function is
notexecuted. only a guess.
For 2):Hmm, I understand.So you need some kind of registry. Maybe something
like this (Just a quick hack):
var ChannelReg = new (function(){
var events = {}; this.addOnJoin = function (channel,
callback){ if(!events['join']){ events['join'] =
{}; Ape.addEvent('join'), function(user, channel) {
if
(events['join'][channel.getProperty('name')] === true) {
callback.call(user, channel); }
} }
events['join'][channel.getProperty('name')] = true; }
this.removeOnJoin = function (channel, callback){
events['join'][channel.getProperty('name')] = false; }
})();
This is a Singleton and you can use it like this:
var chan = Ape.mkChan("myChan");
ChannelReg.addOnJoin(chan, function(user, channel){
Ape.log("onJoin");});
ChannelReg.removeOnJoin(chan);
Timo
--- nouknouk <[email protected]> schrieb am Mo, 15.3.2010:
Von: nouknouk <[email protected]>
Betreff: [APE Project] Re: 1) [SSJS] pipe.onSend callback never called. 2)
[SSJS] are 'join' and 'left' events for one specific channel ?
An: "APE Project" <[email protected]>
Datum: Montag, 15. März, 2010 18:21 Uhr
Hi,
ansd first, thanks for you reply.
> For 1):Just an idea, but maybe you have to listen for the appropriateuser
> pipe´s onSend event, instead of the channel´s one.
Maybe I mis-explained (or mis-understood your answer), but my goal is
to have one channel wrapped in an
independant class.
When someone belonging to this channel sends a RAW, I would like to
notify the right instance of my class.
So I don't want to attach anything to any user, but only on the
channel itself.
For 2)
> your workarounds are all fine.
I don't like those two workaround explained before, because:
- workaround 1) means adding code into the global scope while I'd
prefer my class to be completely independant from external code and
fully sufficient for its needs.
- workaround 2) is not really efficient in terms of scalability: if I
instanciate 1000 times myClass, that means for each event the APE
server will have to execute 1000 functions for maximum 1 case where it
is usefull.
Best regards,
Nouk²
--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen
Massenmails.
http://mail.yahoo.com
--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/
__________________________________________________
Do You Yahoo!?
Sie sind Spam leid? Yahoo! Mail verfügt über einen herausragenden Schutz gegen
Massenmails.
http://mail.yahoo.com
--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/