No commit activity in last 3 years
No release in over 3 years
Private pub/sub messaging in Rails through Faye. Modified the private pub gem from https://github.com/ryanb/private_pub to make it customizable. Removed js support
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 2.8.0

Runtime

>= 0
 Project Readme

Private Pub Plus

Private Pub Plus is a Ruby gem for use with Rails to publish and subscribe to messages through Faye. It allows you to easily provide real-time updates through an open socket without tying up a Rails process. All channels are private so users can only listen to events you subscribe them to.

Inspired by Private pub Gem Watch RailsCasts Episode 316 for a demonstration of Private Pub.

Setup

Add the gem to your Gemfile and run the bundle command to install it. You'll probably want to add "thin" to your Gemfile as well to serve Faye.

gem "private_pub_plus", git: "git://github.com/amritsingh/private_pub.git"
gem "thin"

Run the generator to create the initial files.

rails g private_pub_plus:install

This will generate a file in Rails root directory - 'private_pub.ru'. Authentication of subscribe and publish messages can be modified based on the needs of the application.

Next, start up Faye using the rackup file that was generated.

rackup private_pub.ru -s thin -E production

Usage

Use the publish_to method to send data to that channel.

PrivatePubPlus.publish_to "/messages/new", :chat_message => "Hello, world!" do |channel, data|
  # construct a message here. This message is sent to the subscribed clients e.g.
  # {:channel => channel, :data => {:channel => channel, :data => data, :time => Time.now}, :ext => {:private_pub_token => <secret_token from config/private_pub.yml>}}
end