From 087905492601a55ff53541ef469526051c30aa0b Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 8 Dec 2024 10:40:08 +0800 Subject: Proper UID handling --- main.go | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index b730b9d..15a885c 100644 --- a/main.go +++ b/main.go @@ -30,26 +30,23 @@ func main() { log.Fatal(err) } - client := &Client{ - conn: &conn, - Server: self, - State: ClientStatePreRegistration, - UID: "blah", - Nick: "*", - } - // TODO: Add to the UID table and make actually unique UIDs go func() { - defer func() { - client.Teardown() - (*client.conn).Close() - // TODO: Unified client clean-up - }() defer func() { raised := recover() if raised != nil { slog.Error("connection routine panicked", "raised", raised) } }() + defer func() { + conn.Close() + }() + client, err := NewLocalClient(&conn) + if err != nil { + slog.Error("cannot make new local client", "error", err) + } + defer func() { + client.Teardown() + }() client.handleConnection() }() } -- cgit v1.2.3