Skip to content

Commit b0f361b

Browse files
author
Christopher Strauss
committed
system sends message into chat
1 parent bf7b93b commit b0f361b

File tree

6 files changed

+34
-2
lines changed

6 files changed

+34
-2
lines changed

src/main/client/public/stone1.wav

-218 KB
Binary file not shown.

src/main/client/public/stonenew.wav

175 KB
Binary file not shown.

src/main/client/src/feature/game/Game.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ function Board({gameState, setGameState}) {
103103
}
104104
if (!howler.current) {
105105
howler.current = new Howl({
106-
src: ["/app/stone1.wav"],
106+
src: ["/app/stonenew.wav"],
107107
onloaderror: (id, error) => {
108108
throw new Error(id + ": " + error)
109109
},

src/main/client/src/feature/game/GamePanel.jsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,17 @@ function Panel({gameState, setGameState}) {
7171
let movesLength = gameState.moves.length
7272
let navigate = useNavigate()
7373
let onExit = useCallback(() => {
74+
stompClient.publish({
75+
destination: "/app/chat/send/",
76+
body: JSON.stringify({
77+
message: "X",
78+
id: gameId,
79+
system: true,
80+
join: false,
81+
}),
82+
})
7483
navigate(base + "/lobby")
75-
}, [navigate])
84+
}, [navigate, stompClient, gameId])
7685
let onPass = useCallback(() => {
7786
stompClient.publish({
7887
destination: "/app/game/move",

src/main/client/src/feature/lobby/ActiveGames.jsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
useState,
44
useEffect,
55
useContext,
6+
useCallback,
67
} from "react"
78
import {
89
twJoin,
@@ -61,6 +62,18 @@ export function ActiveGames() {
6162
}
6263

6364
function ActiveGame({game}) {
65+
let stompClient = useContext(StompContext)
66+
let onJoin = useCallback((d) => {
67+
stompClient.publish({
68+
destination: "/app/chat/send/",
69+
body: JSON.stringify({
70+
message: "X",
71+
id: game.id,
72+
system: true,
73+
join: true,
74+
}),
75+
})
76+
}, [stompClient])
6477
let navigate = useNavigate()
6578
let classes = twJoin(
6679
"contents",
@@ -75,6 +88,7 @@ function ActiveGame({game}) {
7588
return (
7689
<div
7790
onClick={() => {
91+
onJoin()
7892
navigate(base + "/game/" + game.id)
7993
}}
8094
className={classes}

src/main/client/src/feature/lobby/OpenGames.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ export function OpenGames() {
7272
},
7373
body: JSON.stringify(d),
7474
})
75+
stompClient.publish({
76+
destination: "/app/chat/send/",
77+
body: JSON.stringify({
78+
message: "X",
79+
id: d.game.id,
80+
system: true,
81+
join: true,
82+
}),
83+
})
7584
navigate(base + "/game/" + d.game.id)
7685
}), [auth, navigate])
7786
return (

0 commit comments

Comments
 (0)