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/