21 lines
387 B
TypeScript
21 lines
387 B
TypeScript
|
import useWebSocketConnection from "./useWebSocketConnection";
|
||
|
|
||
|
function useBackendData() {
|
||
|
|
||
|
const { onMessage, sendMessage } = useWebSocketConnection();
|
||
|
|
||
|
const { roomData, setRoomData } = useRoomData()
|
||
|
|
||
|
|
||
|
onMessage(
|
||
|
(messageString) => {
|
||
|
const messageObject = JSON.parse(messageString)
|
||
|
|
||
|
!!messageObject.roomData && setRoomData(messageObject.roomData)
|
||
|
|
||
|
}
|
||
|
)
|
||
|
|
||
|
|
||
|
}
|