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