networking protocol refactor

This commit is contained in:
2024-09-28 23:26:06 -06:00
parent a97bd301d5
commit 15e7f20f1a
5 changed files with 397 additions and 480 deletions
+17 -1
View File
@@ -44,7 +44,23 @@ func LobbyListen() {
log.Println(err)
continue
}
go l.HandleLobbyConnection(conn)
go func() {
client, msgOut := l.InitialConnectionHandler(conn)
_, 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)
if err != nil {
slog.Error("error marshalling disconnect message on player connect")
}
l.BroadcastToLobby(msg)
}
go l.HandleLobbyConnection(client)
}()
}
}