server Namespace Ape.user

Summary

File
<./src/Ape_Server/modules/libape-spidermonkey.c>

user Namespace Detail

Ape.user
Creates an user object.

The user object is created by ape when an CONNECT command is successful, or via an Ape.addUser event

For a nuser object you can:

  • Set/Get public or privates properties
  • Send a raw to the user's pipe
  • Add function to the prototype (Ape.user)
File:
<./src/Ape_Server/modules/libape-spidermonkey.c>
Example
//You can set private properties on each user object,
// simply set a javascript property of the user.
Ape.addEvent("adduser", function(user) {
	var res = {'foo': bar};
	user.safe = res;							//private
	for (var key in res) {
		if (res.hasOwnproperty(key)) {
			user.setProperty(key, res[key]);	//public
		}
	}
});
Ape.registerCmd("helloworld", function(params, info) {
	Ape.log(info.user.safe.foo);
	Ape.log(info.user.getProperty('foo');
});
See:

Summary

Own
Attributes Type Name Description
<static>   Ape.user pipe Each user has a pipe object where you can send raw's etc.

<static> Ape.user pipe

Each user has a pipe object where you can send raw's etc...
Examples
user.pipe.sendRaw("RAW": {'foo': 'bar'});
var pubid = user.pipe.getProperty('pubid');

Summary

Own
Methods Attributes Methods Name Methods Description
<static>   Ape.user. delProperty (name) Delete a public property from a user.
<static>   Ape.user. getProperty (name) Get a public property of a user.
<static>   Ape.user. join (channel) Forces the user to join a specific channel.
<static>   Ape.user. left (channel) Forces the user to leave a specific channel.
<static>   Ape.user. quit () User has quit the APE.
<static>   Ape.user. setProperty (key, value) Set a public property on a user object.

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

Delete a public property from a user.

The property 'pubid', ip and 'sessid' cannot be removed.

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

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

Get a public property of a user.

By default each user has as sessid, ip and pubid propert.

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

<static> {boolean} Ape.user. join (channel)

Forces the user to join a specific channel.
Parameters:
{string|channel} channel The channel to join
Returns:
{boolean} true if succesfull
Examples
Ape.registerCmd('entry', true, function(user, infos) {
	user.join('*level1');
});
Ape.registerHookCmd("connect", function(params, cmd) {
	cmd.user.join('testChannel');
	return 1;
});
See:
Ape.getUserByPubid
Ape.user
Ape.user.left
Ape.user.quit

<static> {void} Ape.user. left (channel)

Forces the user to leave a specific channel.
Parameters:
{string|channel} channel The channel to leave
Returns:
{void}
Example
Ape.registerCmd('leaveMain', true, function(user, infos) {
	user.left('main_channel');
});
See:
Ape.getUserByPubid
Ape.user
Ape.user.join
Ape.user.quit

<static> {void} Ape.user. quit ()

User has quit the APE.
Returns:
{void}
Example
Ape.registerCmd('signoff', true, function(user, infos) {
	user.quit();
});
See:
Ape.getUserByPubid
Ape.user
Ape.user.left
Ape.user.join

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

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