I use private_pub to implement a personalized chat-like application.
Here is my story: as a user, I would like to receive a message when my partner leaves the chat - closes the window, etc.
Looking through the Faye Monitoring docs , my attempt to bind to unsubscribe:
require "bundler/setup"
require "yaml"
require "faye"
require "private_pub"
require "active_support/core_ext"
Faye::WebSocket.load_adapter('thin')
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 "[#{Time.now}] Client #{client_id} joined #{channel}"
end
wts_pubsub.bind(:unsubscribe) do |client_id, channel|
puts "[#{Time.now}] Client #{client_id} disconnected from #{channel}"
PrivatePub.publish_to channel, { marius_says: 'quitter' }
end
run wts_pubsub
but I keep getting timeouts: [ERROR] [Faye::RackAdapter] Timeout::Error
Getting started PrivatePub#publish_to, the data retains what I expect both when publishing from Rails and in the private_pub application, but the private_pub application continues to hang.
How do I make publishing from private_pub work?
source
share