Created
February 4, 2019 20:15
-
-
Save gregohardy/68aa6ebae1690c5eff153be491e16ffc to your computer and use it in GitHub Desktop.
Faye messaging ruby example
This file contains 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 '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 | |
} |
This file contains 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
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' |
This file contains 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 '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 | |
} |
This file contains 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
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