Close connection on ctrl+c
This commit is contained in:
parent
effa00b001
commit
794915942c
|
@ -10,5 +10,9 @@ client.hook_chat do |msg|
|
|||
puts "chat: #{msg}"
|
||||
end
|
||||
|
||||
Signal.trap('INT') do
|
||||
client.disconnect
|
||||
end
|
||||
|
||||
client.connect('localhost', 8303, detach: false)
|
||||
```
|
||||
|
|
|
@ -68,6 +68,7 @@ class TwClient
|
|||
end
|
||||
|
||||
def disconnect
|
||||
puts "disconnecting."
|
||||
unless @netbase.nil?
|
||||
@netbase.send_packet([NET_CTRLMSG_CLOSE], 0, control: true)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue