just shit

This commit is contained in:
Beric Bearnson 2024-08-08 18:08:55 -06:00
parent 3dc24b6bf2
commit f7eaa0d08d

View File

@ -55,6 +55,17 @@ func Listen() {
go handleLobbyConnection(conn)
}
}()
go func() {
for {
conn, err := listener.Accept()
if err != nil {
log.Println(err)
continue
}
go handleGameConnection(conn)
}
}
}
func handleGameConnection(conn net.Conn) {
@ -62,6 +73,17 @@ func handleGameConnection(conn net.Conn) {
messageBytes := make([]byte, 126)
n, err := conn.Read(messageBytes)
if err != nil {
log.Printf("Error reading game ID on connection", err)
}
gameID, err := string(messageBytes[:n])
if err != nil {
log.Printf("Game id was not a string?", err)
}
for {
n, err := conn.Read(messageBytes)
if err != nil {
@ -69,14 +91,13 @@ func handleGameConnection(conn net.Conn) {
return
}
if isDone, err := handleGameMessage(conn, messageBytes[:n]); err != nil {
if isDone, err := handleGameMessage(gameID, conn, messageBytes[:n]); err != nil {
return
}
}
}
func handleGameMessage(conn net.Conn, message GameMessage) error {
return nil
}