Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
tag: v0.1.5
Fetching contributors…

Cannot retrieve contributors at this time

executable file 72 lines (60 sloc) 1.438 kB
#!/usr/bin/env ruby
require 'rubygems'
require File.dirname(__FILE__) + '/lib/pelvis'
require File.dirname(__FILE__) + '/examples/actors/herault'
require File.dirname(__FILE__) + '/examples/actors/echo'
def connect_herault
Pelvis.connect(:local, :identity => "herault", :advertise => false) do |agent|
agent.add_actor Herault
agent.on_advertised do
puts "herault is ready"
connect_foo
end
end
end
def connect_foo
Pelvis.connect(:local, :identity => "foo") do |agent|
agent.add_actor Echo
agent.on_advertised do
puts "foo is ready"
connect_bar
end
end
end
def connect_bar
Pelvis.connect(:local, {:identity => "bar"}) do |agent|
agent.on_advertised do
puts "bar is ready"
r = agent.request(:all, "/do/echo", {}, :identities => ["foo"])
r.on_received do |data|
puts data[:output]
end
r.on_completed do |event|
puts event
EM::stop_event_loop
end
prompt_for_data do |data|
puts "SENDING: #{data}"
r.put :input => data
end
end
end
end
def prompt_for_data(&block)
op = proc { $stdin.gets }
cb = proc {|data|
if "LQUIT" === data.chomp.upcase
EM::stop_event_loop
else
block.call(data) unless block.nil?
EM::defer(op, cb)
end
}
EM::defer(op, cb)
end
if ENV["DEBUGGER"]
Pelvis.logger.level = Logger::DEBUG
end
EM.run do
connect_herault
end
Jump to Line
Something went wrong with that request. Please try again.