I am using a ruby gem called PrivatePub and this uses Faye to offer PubSub messaging
The PrivatePub gem offers a couple of view based helpers to subscribe / send a message to a particular topic. I am looking to extend PrivatePub to include an API call which will give me the ID of each of the current subscription objects connected to Faye. Can somebody explain how this can be achieved or help me find another way to work out all the current subscriptions from the PrivatePub api.
Since version 0.7, Faye includes an API for monitoring activity going on within the engine. This means you can attach event listeners to monitor the creation and destruction of client sessions, find out when clients subscribe and unsubscribe from channels, and watch published messages.
You attach an event listener to your server like so:
var bayeux = new Faye.NodeAdapter({mount: '/faye', timeout: 45})
bayeux.on('handshake', function(clientId) {
// event listener logic
})
The available events are:
handshake [clientId] – Triggered when a new client connects and is issued with an ID.
subscribe [clientId, channel] – Triggered when a client subscribes to a channel. This does not fire if a /meta/subscribe message is received for a subscription that already exists.
unsubscribe [clientId, channel] – Triggered when a client unsubscribes from a channel. This can fire either because the client explicitly sent a /meta/unsubscribe message, or because its session was timed out by the server.
publish [clientId, channel, data] – Triggered when a non-/meta/** message is published. Includes the client ID of the publisher (which may be null), the channel the message was sent to and the data payload.
disconnect [clientId] – Triggered when a client session ends, either because it explicitly sent a /meta/disconnect message or because its session was timed out by the server.
I hope that this helps