Last active
August 29, 2015 14:05
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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