Skip to content

Commit 9fc64a0

Browse files
committedJul 16, 2024
add socket handler
1 parent cecbf91 commit 9fc64a0

File tree

10 files changed

+407
-76
lines changed

10 files changed

+407
-76
lines changed
 

‎.gitignore

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# production
12+
/build
13+
14+
# misc
15+
.DS_Store
16+
.env.local
17+
.env.development.local
18+
.env.test.local
19+
.env.production.local
20+
21+
npm-debug.log*
22+
yarn-debug.log*
23+
yarn-error.log*

‎README.md

-1
This file was deleted.

‎backend/main.go

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package main
33
import (
44
"log"
55
"net/http"
6+
"peaksel/server"
67
"peaksel/storage"
78
)
89

@@ -11,6 +12,7 @@ func main() {
1112
defer rdb.Close()
1213

1314
http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
15+
server.HandleWebSocket(w, r, rdb)
1416

1517
})
1618
log.Println("Starting server on :8080")

‎backend/server/websocket.go

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package server
22

33
import (
4+
"fmt"
45
"log"
56
"net/http"
67
"peaksel/handlers"
@@ -36,6 +37,8 @@ func HandleWebSocket(w http.ResponseWriter, r *http.Request, rdb *storage.RedisC
3637
break
3738
}
3839

40+
fmt.Print("pixel: ", pixel)
41+
3942
// Handle the pixel event
4043
handlers.HandlePixelEvent(rdb, conn, pixel)
4144
}

‎docker-compose.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
version: '3'
2+
services:
3+
backend:
4+
build: ./backend
5+
ports:
6+
- "8080:8080"
7+
depends_on:
8+
- redis
9+
redis:
10+
image: "redis:alpine"
11+
ports:
12+
- "6379:6379"

0 commit comments

Comments
 (0)
Please sign in to comment.