Compare commits
1 Commits
6d078f3adb
...
db2d7d0252
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db2d7d0252 |
@@ -1,6 +1,7 @@
|
|||||||
package c4game
|
package c4game
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -119,7 +120,8 @@ func HandleGameEvents(store *connect4.Store, nc *nats.Conn, sm *scs.SessionManag
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendPing := func() error {
|
sendPing := func() error {
|
||||||
return sse.PatchSignals([]byte(fmt.Sprintf(`{"lastPing":%d}`, time.Now().UnixMilli())))
|
ping, _ := json.Marshal(map[string]int64{"lastPing": time.Now().UnixMilli()})
|
||||||
|
return sse.PatchSignals(ping)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send initial render and ping
|
// Send initial render and ping
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package snakegame
|
package snakegame
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -125,7 +126,8 @@ func HandleSnakeEvents(snakeStore *snake.SnakeStore, nc *nats.Conn, sm *scs.Sess
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendPing := func() error {
|
sendPing := func() error {
|
||||||
return sse.PatchSignals([]byte(fmt.Sprintf(`{"lastPing":%d}`, time.Now().UnixMilli())))
|
ping, _ := json.Marshal(map[string]int64{"lastPing": time.Now().UnixMilli()})
|
||||||
|
return sse.PatchSignals(ping)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send initial render and ping
|
// Send initial render and ping
|
||||||
|
|||||||
Reference in New Issue
Block a user