Skip to content
Aravind edited this page Jun 10, 2013 · 7 revisions

The core codebase is in /core/, the entry point is core.js and it's exposed as Node.js module with the following API:

core.init(gateways)

This is called by the launcher, and it provides a list of gateways as a hashmap. Each gateway should conform to the gateway API.

core.send(message, callback)

This is called by gateways. The message object contains the from and to information necessary for routing. core.send identifies the rooms and accounts that should receive the message, adds the message to these rooms' archives and invokes the gateways' send() methods for these accounts.

core.send() might have other side effects depending on the message type, e.g. sending a 'follow' message creates a 'follow' relationship between the 'from' and 'to' nodes.

The callback will get the updated message object with the server timestamp and message id.

To see all the different message types and a description of their side effects, see Messages.

core.messages(query, callback)

This is called by gateways to retrieve messages from the archive. query must be an object can have one or more the following fields:

  • from, to, type: A single string or an array of strings.
  • since, until: A number (unix timestamp with millisecond precision).
  • label: Not yet implemented.

It returns at most 256 results, oldest first. If 'until' is specified, and since is not, the last retrieved message is guaranteed to be the latest available message with a timestamp less than the limit.

core.labels(query, callback)

Not implemented: Returns an array of labels. Queries can pass room

core.rooms(query, callback)

Not implemented: Returns an array of rooms. Queries can pass follows, present, until and since (until and since are id's, used for pagination).

core.accounts(query, callback)

Not implemented: Returns an array of accounts. Queries can pass room and gateway.

core.room(id, callback)

Retrieves a single room from its id.

core.room(room, callback)

Saves a room's updated metadata. To delete, add a property delete: true to the room object (all other properties except id are then optional). Callback has no arguments.

core.account(id, callback)

Retrieves a single account from its id.

core.account(account, callback)

Saves an account's updated metadata.

Clone this wiki locally