Project

General

Profile

« Previous | Next » 

Revision 848944dc

Added by Marc Dequènes almost 14 years ago

  • ID 848944dcce9d9a0f132a21d2ca01a8824a34e5b4

[evol] Task-based client DSL §6 (added botnet 'ask' subtask)

View differences:

bin/test_client
# to test the closure through the inner instance_eval calls
toto = true
c = 0
task "compare stuff" do
# ask :MapMaker, :ver1, "/api_version"
# ask :Librarian, :ver2, "/api_version"
wait_notification :task, {:topic => "HELOz"}, 5 do |subtask, msg|
puts "POUET NOTIF"
subtask.finish
end
send_notification :task, {:topic => "HELO"}
wait_timer 2, true do |subtask|
c += 1
puts "TIMER !!!"
STDOUT.flush
subtask.finish if c == 10
end
ask "MapMaker", :ver1, "/api_version"
ask "Librarian", :ver2, "/api_version"
ask "MapMaker", :zones, "/DNS/Zones"
on_error do
puts "PLOUF"
pp errors
......
puts "OK"
pp errors
pp results
# puts "Tadam: " + (ver1 == ver2 ? "same" : "different")
puts "Tadam: " + (results[:ver1] == results[:ver2] ? "same" : "different")
meet "waiter", :zzz
STDOUT.flush
on_success do
......
meet "compare stuff", :zzz
on_success do
puts "OK waiter"
#stop_bot :at_once
stop_bot :when_finished
end
end
conversation_with "MapMaker" do
on_error do
puts "Halalalala !"
end
thread "super taiste" do
call :ver, "/api_version"
call :zones, "/DNS/Zones" if toto
on_error do
puts "Sniff !"
pp reply
end
on_success do
puts "Yahou !"
pp reply
call :gogogo, "/DNS"
on_error do
pp "Plouf"
pp reply
end
on_success do
pp "Hop!"
pp reply
send_notification 'meetpoint', { :topic => "MYNOTIF", :msg => "plop" }
end
end
end
#stop_bot :at_once
stop_bot :when_finished
end
# conversation_with "MapMaker" do
# on_error do
# puts "Halalalala !"
# end
# thread "super taiste" do
# call :ver, "/api_version"
# call :zones, "/DNS/Zones" if toto
# on_error do
# puts "Sniff !"
# pp reply
# end
# on_success do
# puts "Yahou !"
# pp reply
# call :gogogo, "/DNS"
# on_error do
# pp "Plouf"
# pp reply
# end
# on_success do
# pp "Hop!"
# pp reply
# send_notification 'meetpoint', { :topic => "MYNOTIF", :msg => "plop" }
# end
# end
# end
# #stop_bot :at_once
# stop_bot :when_finished
# end
conversation_with "Librarian" do
thread "taistouille" do
call :sdf, "/Gruik"
on_success do
puts "Librarian GoGoGo!"
pp reply
wait_notification 'meetpoint', { :topic => "MYNOTIF" }
on_success do
puts "NOTIF!"
pp reply
end
end
end
end
# conversation_with "Librarian" do
# thread "taistouille" do
# call :sdf, "/Gruik"
# on_success do
# puts "Librarian GoGoGo!"
# pp reply
# wait_notification 'meetpoint', { :topic => "MYNOTIF" }
# on_success do
# puts "NOTIF!"
# pp reply
# end
# end
# end
# end
end
end
end

Also available in: Unified diff