How can I find the number of current signatures using PrivatePub and Faye in rails

I use a ruby โ€‹โ€‹pearl called PrivatePub and it uses Faye to offer PubSub posts

The PrivatePub hard drive offers a couple of presentation-based helpers to subscribe / send messages on a specific topic. I want to extend PrivatePub to include an API call that will give me the identifier of each of the current subscription objects associated with Faye. Can someone explain how this can be achieved or help me find another way to work out all the current subscriptions from the PrivatePub api.

+4
source share
1 answer

Starting with version 0.7, Faye includes an API for monitoring activity occurring inside the engine. This means that you can attach event listeners to monitor the creation and destruction of client sessions, find out when clients subscribe and unsubscribe from channels, and view published messages.

You attach an event listener to your server as follows:

var bayeux = new Faye.NodeAdapter({mount: '/faye', timeout: 45})

bayeux.on('handshake', function(clientId) {
  // event listener logic
})

Available events:

  • handshake [clientId] - starts when a new client connects and issues with an identifier.

  • subscribe [clientId, channel] - starts when the client subscribes to the channel. This does not work if the message / meta / subscribe is received for an existing subscription.

  • [clientId, channel] - , . , /meta/unsubscribe , .

  • publish [clientId, channel, data] - , non/meta/**. ( ), , , .

  • disconnect [clientId] - , , , //, , .

,

+3

Source: https://habr.com/ru/post/1618217/


All Articles