From a8e6adfb046ca40ee5ab9e962628e9a2deccdb39 Mon Sep 17 00:00:00 2001 From: Beric Bearnson <37596980+bericyb@users.noreply.github.com> Date: Thu, 24 Oct 2024 21:36:15 -0600 Subject: [PATCH] logs --- cmd/server/main.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/cmd/server/main.go b/cmd/server/main.go index 41f7966..bd710e9 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -58,23 +58,22 @@ func LobbyListen() { client, msgOut, err := l.InitialConnectionHandler(conn) if err != nil { conn.Write(msgOut) - return - } - fmt.Println("new client", client) - - _, err = conn.Write(msgOut) - if err != nil { - slog.Debug("error writing to new player... disconnecting") - // msg, err := lobby.Marshal(lobby.DisconnectData{ - // From: client.Username, - // }, lobby.Disconnect) + } else { + fmt.Println("new client", client) + _, err = conn.Write(msgOut) if err != nil { - slog.Error("error marshalling disconnect message on player connect") + slog.Debug("error writing to new player... disconnecting") + msg, err := lobby.Marshal(lobby.DisconnectData{ + From: client.Username, + }, lobby.Disconnect) + if err != nil { + slog.Error("error marshalling disconnect message on player connect") + } + l.BroadcastToLobby(msg) } - // l.BroadcastToLobby(msg) - } - go l.HandleLobbyConnection(client) + go l.HandleLobbyConnection(client) + } }() } }