var Gitter = require('{%= name %}');
{%= apidocs('index.js') %}
The following events will be emitted after .listen has been called and are available to be listened for:
The chatMessages
event will be emitted when anything happens to a chat message.
Check the .operation
property to see what is happening to the message:
gitter.on('chatMessages', function(msg, room) {
console.log(msg);
switch (msg.operation) {
case 'create':
// new message being created
break;
case 'patch':
// message was updated (e.g. someone marked it as "read")
break;
}
});
The events
event will be emitted when an event in the room occurs.
gitter.on('events', function(event, room) {
console.log(event);
});
The users
event will be emitted when a user joins or leaves a room:
gitter.on('users', function(user, room) {
console.log(user);
});