From a7391903837412e25198c395af043aaf4d3e4b4c Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Sun, 17 Sep 2023 18:22:38 +0200 Subject: [PATCH] Fix reconnect crash --- lib/net_base.rb | 4 ++++ lib/teeworlds_client.rb | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/net_base.rb b/lib/net_base.rb index 9aef0c5..51be339 100644 --- a/lib/net_base.rb +++ b/lib/net_base.rb @@ -63,6 +63,10 @@ class NetBase # // TTTTTTTT # // TTTTTTTT # // TTTTTTTT + if @s.nil? + puts "Error: no active socket" + return + end flags_bits = PacketFlags.new(opts).bits ack = @ack ip = @ip diff --git a/lib/teeworlds_client.rb b/lib/teeworlds_client.rb index ba20ca7..19224ab 100644 --- a/lib/teeworlds_client.rb +++ b/lib/teeworlds_client.rb @@ -191,8 +191,9 @@ class TeeworldsClient def disconnect puts 'disconnecting.' - send_ctrl_close + send_ctrl_close unless @s.nil? @s&.close + @s = nil @signal_disconnect = true end