Skip to content

Instantly share code, notes, and snippets.

@gregohardy
Created February 4, 2019 20:15
Show Gist options
  • Save gregohardy/68aa6ebae1690c5eff153be491e16ffc to your computer and use it in GitHub Desktop.
Save gregohardy/68aa6ebae1690c5eff153be491e16ffc to your computer and use it in GitHub Desktop.
Faye messaging ruby example
require 'rubygems'
require 'bundler/setup'
require 'faye'
EM.run {
ENDPOINT = 'http://localhost:8080/bayeux'
puts 'Connecting to ' + ENDPOINT
pong = Faye::Client.new(ENDPOINT)
publish = pong.publish('/ping', {:message => "build message"})
publish.callback do
puts "[PUBLISH SUCCEEDED]"
EM.stop()
end
publish.errback do |error|
puts "[PUBLISH FAILED]"
EM.stop()
end
}
source 'https://rubygems.org'
gem 'cookiejar', '>= 0.3.0'
gem 'em-http-request', '>= 0.3.0'
gem 'faye-websocket', '>= 0.9.1'
gem 'multi_json', '>= 1.0.0'
gem 'rack', '>= 1.0.0'
gem 'websocket-driver', '>= 0.5.1'
gem 'permessage_deflate', '>= 0.1.0'
gem 'eventmachine', '>= 0.12.0'
gem 'faye'
gem 'pry-byebug'
require 'rubygems'
require 'bundler/setup'
require 'faye'
EM.run {
ENDPOINT = 'http://localhost:8080/bayeux'
puts 'Connecting to ' + ENDPOINT
ping = Faye::Client.new(ENDPOINT)
ping.subscribe('/ping') do |message|
puts "Build is done! message is [#{message["message"]}]"
EM.stop()
end
}
docker-faye-server
npm install
npm start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment