Faye

Simple pub/sub messaging for the web

Browser client

Extensions

Faye clients support an extension system that lets you intercept messages as they pass between the client and the server. To add an extension to a client, just call:

client.addExtension(extension);

extension should be an object with an incoming() or outgoing() method (or both). These methods accept a message and a callback function, and should call the callback with the message after any necessary modifications have been made. For example, a simple logging extension would look like:

Logger = {
  incoming: function(message, callback) {
    console.log('incoming', message);
    callback(message);
  },
  outgoing: function(message, callback) {
    console.log('outgoing', message);
    callback(message);
  }
};

client.addExtension(Logger);

For more information on writing extensions, see the Node server or Ruby server documentation.