server Class Ape.channel

Summary

Channel object (For many-to-many communcation)
File
<./src/Ape_Server/modules/libape-spidermonkey.c>

channel Class Detail

Ape.channel ()
The channel object is created when an user connects to an nonexistent channel or if it is created on the server with Ape.mkChan.
File:
<./src/Ape_Server/modules/libape-spidermonkey.c>
Examples
var channel = Ape.mkChan('my_channel');
Ape.addEvent("join", function(user, channel) {
	Ape.log("New user has joined the channel (" + channel.getProperty('name') + ") :)");
});
See:

Summary

Own
Attributes Type Name Description
<static>   Ape.channel userslist

This variable is mootools Hash that contain all the user on the channel.

<static> Ape.channel userslist

This variable is mootools Hash that contain all the user on the channel.

This is provided by the script framework/userslist.js

Examples
var chan = Ape.getChannelByName('test');
chan.userslist.each(function(user) {
	Ape.log(user.getProperty('pubid'));
});
//a little bit off-topic but nevertheless very interesting
function sendToMany(users, cmd, data) {
	var chan = Ape.mkChan("*" + +new Date());
		for (var i = 0; i < users.length; i++) {
			users[i].join(chan);
		}
		chan.pipe.sendRaw(cmd, data);
		Ape.delChan(chan);
}

Summary

Own
Methods Attributes Methods Name Methods Description
<static>   Ape.channel. delProperty (name) Delete a public property from a channel.
<static>   Ape.channel. getProperty (name) Get a public property of a channel.
<static>   Ape.channel. isInteractive () Check if a channel is interactive.
<static>   Ape.channel. setProperty (key, value) Set a public property from a channel.

<static> {void} Ape.channel. delProperty (name)

Delete a public property from a channel.

The property 'pubid' and 'name' cannot be removed.

Parameters:
{string} name The name of the property to unset
Returns:
{void}
Example
channel.delProperty('foo');
See:

<static> {mixed} Ape.channel. getProperty (name)

Get a public property of a channel.

By default each channel has a name and pubid property.

Parameters:
{string} name The name of the property to get
Returns:
{mixed} the property value or undefined
Example
var pub = channel.getProperty('pubid');
See:

<static> {boolean} Ape.channel. isInteractive ()

Check if a channel is interactive.

A channel can be set to readonly if the channelname starts with a '*'

Returns:
{boolean} interactive
Example
var channel = Ape.mkChan('*foo');
Ape.log('is interactive: ' + channel.isInteractve());
See:

<static> {void} Ape.channel. setProperty (key, value)

Set a public property from a channel.
Parameters:
{string} key The name of the property to set
{mixed} value The value to set
Returns:
{void}
Examples
channel.setProperty('foo', 'bar');
channel.setProperty('foo', {'bar':' 1});
See: