Skip to content

Commit 46ade7d

Browse files
committed
fix: emit changes to ALL clients (insteads of only one)
1 parent 49e1a45 commit 46ade7d

File tree

2 files changed

+1
-4
lines changed

2 files changed

+1
-4
lines changed

src/client/Components/Overlay.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const Overlay = () => {
1010
const [labelAndTallyState, setLabelAndTallyState] = useState<
1111
ILabelAndTallyState[]
1212
>([]);
13-
const [forceUpdate, setForceUpdate] = useState<boolean>(false);
1413

1514
useEffect(() => {
1615
const socketClient = io();
@@ -22,14 +21,12 @@ const Overlay = () => {
2221
})
2322
.on(IO.SEND_STATE, (receivedState: ILabelAndTallyState[]) => {
2423
setLabelAndTallyState(receivedState);
25-
setForceUpdate(!forceUpdate);
2624
});
2725
}, []);
2826

2927
return (
3028
<div className="app">
3129
<div>
32-
{forceUpdate ? <div></div> : <div></div>}
3330
{sources.map((source: ISource, index) => (
3431
<SourceOverlay
3532
key={index}

src/server/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ io.on("connection", (socket: any) => {
3131
if (JSON.stringify(oldState) !== JSON.stringify(labelAndTallyState)) {
3232
console.log("State changed");
3333
saveLabelTallyState(labelAndTallyState);
34-
socket.emit(IO.SEND_STATE, labelAndTallyState);
34+
io.sockets.emit(IO.SEND_STATE, labelAndTallyState);
3535
}
3636
}, 100);
3737
const clientTimerSettings = setInterval(

0 commit comments

Comments
 (0)