Thanks! :) On Dec 13, 4:19 am, Anthony Catel <[email protected]> wrote: > Hi Thibaut, > > You forgot to create the channel first. > user.join() will fail if the channel doesn't exist. > > What you can do is : > > if (!$defined(Ape.getChannelByName(params.channels))) > Ape.mkChan(params.channels); > cmd.user.join(params.channels); > > It's a little bit weird to have to create the channel yourself. I'll fix > that later ;) > > Anthony > > Le 12/12/09 11:39, Thibaut a crit : > > > Hi, > > > I'm trying to implement a private chat system with Ruby on Rails and > > Ape. Before 1.0 came out I was using Juggernaut, a Flash plugin with a > > push server. > > > Juggernaut makes it easy to have private rooms thanks to a particular > > callback: subscription_url (login). When a user attempts to subscribe > > to a channel, the push server sends a request to the Rails app and if > > the response code is anything but 200 then the "subscribe" action is > > canceled. > > > I've tried to implement this with Ape but I can't get "cmd.user.join > > (params.channels)" to work properly (the channel variable is correct). > > > Ape.registerHookCmd("JOIN", function(params, cmd) > > { > > ... // Initializing p variable > > > var request = new Http('http://127.0.0.1/ape/connect', 3000); > > request.set('method', 'POST'); > > request.writeObject(p); > > > request.finish(function(result) { > > if (result.status == 200) cmd.user.join(params.channels); > > }); > > > return ["209", "AUTH_IN_PROGRESS"]; > > }); > > > The request is sent asynchronously (I tried to use Prototype or JQuery > > to send a synchronous Ajax request with success / failure callbacks > > but they wouldn't load) so the "return" is executed before the > > "finish" callback is called. I'd expect it to subscribe the user to > > the channel but it doesn't work. > > > However, if I change the "return" value to 1, then the user is > > subscribed twice (the second subscription coming from the "finish" > > callback). > > > I tried to understand how the join command works and tested this: > > (with no other hook) > > > Ape.registerHookCmd("connect", function(params, cmd) { > > cmd.user.join('testChannel'); > > return 1; > > }); > > > ... but it doesn't work (I can verify it with a beforeJoin event or by > > pushing data to the channel). > > > I'm running Mac OS X 10.5 and compiled APE Server from source. > > > Thanks for your help. > > > Thibaut
-- 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/
