Config is now saved and synced when updated

This commit is contained in:
2020-06-07 22:47:53 -05:00
parent ab6edb7a58
commit 151df4ca57
14 changed files with 162 additions and 59 deletions

View File

@@ -19,6 +19,10 @@ module TAC
@data_sent, @data_received = 0, 0
end
def uuid=(id)
@uuid = id
end
def socket=(socket)
@socket = socket

View File

@@ -2,6 +2,7 @@ module TAC
class TACNET
class Connection
TAG = "TACNET|Connection"
attr_reader :client
def initialize(hostname = DEFAULT_HOSTNAME, port = DEFAULT_PORT)
@hostname = hostname
@port = port
@@ -16,7 +17,7 @@ module TAC
handle_connection
end
@packet_handler = PacketHandler.new
@packet_handler = PacketHandler.new(host_is_a_connection: true)
end
def connect(error_callback)
@@ -58,6 +59,14 @@ module TAC
end
end
def puts(packet)
@client.puts(packet)
end
def gets
@client.gets
end
def connected?
!closed?
end

View File

@@ -31,7 +31,7 @@ module TAC
def handle_handshake(packet)
if @host_is_a_connection
# TODO: Set Connection client id to received uuid
$window.backend.tacnet.client.uuid = packet.body
end
end

View File

@@ -65,7 +65,6 @@ module TAC
if @active_client && @active_client.connected?
log.i(TAG, "Too many clients, already have one connected!")
client.close("Too many clients!")
pp @active_client.connected?
else
@active_client = client
# TODO: Backup local config