From Ape Wiki

Jump to: navigation, search

[edit] Control channel access

Here are two server side module samples to show you how to allow or disallow a user to join a channel

[edit] Example with all logic implemented on the server side

    Ape.registerHookCmd('JOIN', function(params, cmd) {
        //First check if channel exists
        var chan = Ape.getChannelByName(params.channels);
        if (!$defined(chan)) { //If channel doesn't exist, create it 
            Ape.mkChan(params.channels);
        }
        /* add some logic code here to check if user is allowed or not to join the channel */
        var allowed = false;
        if (allowed) {
            //Make the user join the channel
            cmd.user.join(params.channels);
        } else {
            return ['101', 'CANT_JOIN_CHANNEL'];
        }
    });

Thanks for being on point and on traegt!

[edit] Sending extra parameters with join

Maybe you might want to add some extra parameters to the join command. You can do it like this:

client.core.request.send('JOIN', {'channels': 'channelName', 'args1': 'hello', 'args2': 'world'});