Pongd: `-n` option, to avoid sending responses.
parent
119ccbca3c
commit
949964e2ec
|
@ -4,12 +4,17 @@ require "./colors"
|
||||||
|
|
||||||
verbosity = 1
|
verbosity = 1
|
||||||
service_name = "pong"
|
service_name = "pong"
|
||||||
|
no_response = false
|
||||||
|
|
||||||
OptionParser.parse do |parser|
|
OptionParser.parse do |parser|
|
||||||
parser.on "-s service_name", "--service-name service_name", "URI" do |optsn|
|
parser.on "-s service_name", "--service-name service_name", "URI" do |optsn|
|
||||||
service_name = optsn
|
service_name = optsn
|
||||||
end
|
end
|
||||||
|
|
||||||
|
parser.on "-n", "--no-response", "Do not provide any response back." do
|
||||||
|
no_response = true
|
||||||
|
end
|
||||||
|
|
||||||
parser.on "-v verbosity", "--verbosity verbosity", "Verbosity (0 = nothing is printed, 1 = only events, 2 = events and messages). Default: 1" do |optsn|
|
parser.on "-v verbosity", "--verbosity verbosity", "Verbosity (0 = nothing is printed, 1 = only events, 2 = events and messages). Default: 1" do |optsn|
|
||||||
verbosity = optsn.to_i
|
verbosity = optsn.to_i
|
||||||
end
|
end
|
||||||
|
@ -45,8 +50,8 @@ service.loop do |event|
|
||||||
puts "#{CBLUE}message type #{event.message.utype}: #{m} #{CRESET}"
|
puts "#{CBLUE}message type #{event.message.utype}: #{m} #{CRESET}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
event.connection.send event.message
|
event.connection.send event.message unless no_response
|
||||||
if verbosity >= 2
|
if verbosity >= 2 && ! no_response
|
||||||
puts "#{CBLUE}message sent#{CRESET}"
|
puts "#{CBLUE}message sent#{CRESET}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Reference in New Issue