Skip to content

Instantly share code, notes, and snippets.

@paulbaumgart
Last active August 29, 2015 14:05
Show Gist options
  • Save paulbaumgart/f6bb71c588425f8a7487 to your computer and use it in GitHub Desktop.
Save paulbaumgart/f6bb71c588425f8a7487 to your computer and use it in GitHub Desktop.
Publishing to Faye using Redis Engine from Rails, without mounting a Faye server
require 'eventmachine'
require 'faye'
require 'faye/redis'
client = Faye::Client.new(Faye::Server.new({
engine: {
type: Faye::Redis
# non-default redis connection config here
}
}))
Thread.new { EM.run } unless EM.reactor_running?
Thread.pass until EM.reactor_running?
EventMachine.next_tick {
client.publish('/some/channel', { data: 'here' })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment