Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add profiling http endpoint #43

Merged
merged 3 commits into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ Server for SpaceCheckers game. Written entirely using only Go's standard library

- Golang 1.21 or newer. Get it from [official site](https://go.dev/dl/)


## How to build

- Simply open up your terminal (or CMD) at this project root directory and run the following command.
Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"sync/atomic"
"time"

_ "net/http/pprof"

"golang.org/x/net/websocket"
)

Expand Down Expand Up @@ -52,7 +54,6 @@ func wsHandler(ws *websocket.Conn) {
Pieces: make([]int32, 12),
Dead: deadChan,
}
defer close(p.Dead)

//for each pair joining, the First will always be RED
if numPlayers.Load()%2 == 0 {
Expand Down Expand Up @@ -107,7 +108,7 @@ func listenForJoins() {
go func(p1, p2 *player.Player) {
//Sleep required for [p2] Client to process prev message
time.Sleep(200 * time.Millisecond)
gameOver := make(chan bool, 1)
gameOver := make(chan bool)
room.RunMatch(p1, p2, gameOver)
<-gameOver //block until match ends
log.Println("🔴 GAME OVER!")
Expand Down
Loading