Pongd: `-n` option, to avoid sending responses.

master
Karchnu 2020-06-04 17:20:03 +02:00
parent 119ccbca3c
commit 949964e2ec
1 changed files with 7 additions and 2 deletions

View File

@ -4,12 +4,17 @@ require "./colors"
verbosity = 1
service_name = "pong"
no_response = false
OptionParser.parse do |parser|
parser.on "-s service_name", "--service-name service_name", "URI" do |optsn|
service_name = optsn
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|
verbosity = optsn.to_i
end
@ -45,8 +50,8 @@ service.loop do |event|
puts "#{CBLUE}message type #{event.message.utype}: #{m} #{CRESET}"
end
end
event.connection.send event.message
if verbosity >= 2
event.connection.send event.message unless no_response
if verbosity >= 2 && ! no_response
puts "#{CBLUE}message sent#{CRESET}"
end