Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Private_pub binding faye unsubscribe
# Run with: rackup -s thin -E production
require "bundler/setup"
require "yaml"
require "faye"
require "private_pub"
require "active_support/core_ext"
PrivatePub.load_config(File.expand_path("../config/private_pub.yml", __FILE__), ENV["RAILS_ENV"] || "development")
wts_pubsub = PrivatePub.faye_app
wts_pubsub.bind(:subscribe) do |client_id, channel|
puts "[#{}] Client #{client_id} joined #{channel}"
wts_pubsub.bind(:unsubscribe) do |client_id, channel|
puts "[#{}] Client #{client_id} disconnected from #{channel}"
PrivatePub.publish_to channel, { marius_says: 'quitter' }
run wts_pubsub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment