Refactor TACNET Client a bit

This commit is contained in:
2023-01-30 16:16:02 -06:00
parent 94cd822b0c
commit 308575dc63
2 changed files with 43 additions and 44 deletions

View File

@@ -1,6 +1,6 @@
module TAC
class TACNET
DEFAULT_HOSTNAME = "192.168.49.1"
DEFAULT_HOSTNAME = "192.168.49.1".freeze
DEFAULT_PORT = 8962
SYNC_INTERVAL = 250 # ms
@@ -30,7 +30,7 @@ module TAC
end
def full_status
_status = status.to_s.split("_").map { |c| c.capitalize }.join(" ")
_status = status.to_s.split("_").map(&:capitalize).join(" ")
if connected?
net_stats = ""
@@ -42,7 +42,7 @@ module TAC
"<b>Status:</b> #{_status}\n\n#{net_stats}"
elsif @connection&.client && @connection.client.socket_error?
"<b>Status:</b> #{_status}\n\n#{@connection.client.last_socket_error.to_s}"
"<b>Status:</b> #{_status}\n\n#{@connection.client.last_socket_error}"
else
"<b>Status:</b> #{_status}"
end
@@ -53,10 +53,10 @@ module TAC
end
def close
if connected?
@connection.close
@connection = nil
end
return unless connected?
@connection.close
@connection = nil
end
def client
@@ -75,4 +75,4 @@ module TAC
Process.clock_gettime(Process::CLOCK_MONOTONIC, :millisecond)
end
end
end
end