Hi!
For 1):Just an idea, but maybe you have to listen for the appropriateuser
pipe´s onSend event, instead of the channel´s one.
For 2)While, ideed, it would be nice to have these events on the channelobject
itself, all the events on APE server are global.And since JS objects are
intended to be augmented, your workarounds are all fine.On the other hand you
could augment the channel object to allow something like this:var chan =
Ape.mkChan('myChannel');chan.addEvent('join', function(user){ [...]});
It´d just need an event dispatcher, which I guess can be found somewhere in
the Ape core, otherwise would not be hard to implement.
Timo
--- nouknouk <[email protected]> schrieb am Mo, 15.3.2010:
Von: nouknouk <[email protected]>
Betreff: [APE Project] 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 14:50 Uhr
Hi,
1) I have some code on server side (latest APE Git version) like that:
var MyClass = new Class({
Implements: [Options],
options: {
instanceId: 1 // an integer
},
instanceId: 0,
channel: null,
initialize: function(options) { try {
this.setOptions(options);
this.instanceId = this.options.instanceId;
this.channel = Ape.mkChan("*mychannel"+this.instanceId);
this.channel.pipe.onSend = function(user, params)
{ Ape.log("[MyClass] onSend()..."); };
} catch(e) { Ape.log("[MyClass] initialize() EXCEPTION: "+e); } },
});
In 'global scope' code, I instanciate MyClass once (with option
instanceId set to '1').
I launch my APE server and then I connect to APE with my browser.
Once my client is connected to APE:
- I join "*myChannel1" : client.core.join("*mychannel1");
- I wait for the 'CHANNEL' reply.
- I call myChannelVar.send("abcdef");
But on server side, the onSend callback fuction is never called.
I don't understand why.
Any idea ?
2) I wondered if there was a way to register events for a specific
channel on server side. I mean having events equivalents to
'beforeJoin', 'join', left' but binded only to ONE channel (and not
all channels of the APE server).
I have a couple of workarounds to do that (*), but I think having such
event at channel level would make sense if there was such feature in
the server's package itself. Don't you think ?
(*) workaround 1 :
// global event written once...
Ape.addEvent('join', function(user, channel) {
if (channel.onJoin != null) {
channel.onJoin(user);
}
}
// ... and for each channel instanciated:
var myChan = Ape.mkChan("myChan");
// add a callback if we want to listen to the event.
myChan.onJoin = function(user) { Ape.log("onJoin"); }
(*) workaround 2 (crappy way):
// for each channel instanciated:
var myChan = Ape.mkChan("myChan");
Ape.addEvent('join', function(user, channel) {
if (channel == myChan) {
Ape.log("onJoin");
}
}
--
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/