teeworlds_network/integration_test/client/multiple_blocks.rb
ChillerDragon fe3e581f86 Make client callbacks arrays
Allows to setup multiple on_* hook blocks as a lib user

closed #10
2022-11-14 10:25:28 +01:00

25 lines
456 B
Ruby
Executable file

#!/usr/bin/env ruby
# frozen_string_literal: true
require_relative '../../lib/teeworlds_client'
client = TeeworldsClient.new
client.on_connected do |_|
puts 'block 1 rcon auth'
client.rcon_auth(password: 'rcon')
end
client.on_connected do |_|
puts 'block 2 rcon shutdown'
client.rcon('shutdown')
end
client.on_disconnect do
puts 'got disconnect'
exit 0
end
# connect and block main thread
client.connect('localhost', 8377, detach: false)