chore: initialise backend

This won't be touched until a basic player prototype is implemented.
The backend itself is implemented in Go.
This commit is contained in:
Abdulmujeeb Raji 2023-07-18 11:58:48 +01:00 committed by Muhammad Nauman Raza
parent a8ddd3d740
commit 5ad18b9027
2 changed files with 41 additions and 0 deletions

3
backend/go.mod Normal file
View file

@ -0,0 +1,3 @@
module github.com/devraza/ambition/backend
go 1.20

38
backend/main.go Normal file
View file

@ -0,0 +1,38 @@
package main
import (
"log"
"net"
"os"
)
const (
serverAddress = "localhost:7764"
)
func main() {
log.Println("Ambition going strong at", serverAddress)
listener, err := net.Listen("tcp", serverAddress)
if err != nil {
log.Fatalln("Failed to initialise TCP listener", err)
}
defer listener.close()
for {
conn, err := listener.Accept()
if err != nil {
log.Println("Failed to accept connection:", err)
continue
}
// Concurrency FTW
go handleConnection(conn)
}
}
func handleConnection(conn net.Conn) {
defer conn.Close()
// TODO implement actual server. Waiting on frontend for this
}