-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(v2): room state persisted in Redis & TRPC endpoints to update state
This way the clients don't confuse each other with individual problems or race conditions. Closes #65
- Loading branch information
Showing
20 changed files
with
889 additions
and
506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { type Logger } from "next-axiom"; | ||
import { Table } from "fpp/components/room/table"; | ||
import { Interactions } from "fpp/components/room/interactions"; | ||
import React from "react"; | ||
import { useHeartbeat } from "fpp/hooks/use-heartbeat.hook"; | ||
import { useRoomState } from "fpp/hooks/use-room-state.hook"; | ||
|
||
export const Room = ({ | ||
roomId, | ||
roomReadable, | ||
userId, | ||
username, | ||
logger, | ||
}: { | ||
roomId: number; | ||
roomReadable: string; | ||
userId: string; | ||
username: string; | ||
logger: Logger; | ||
}) => { | ||
// Listen to room state updates | ||
useRoomState({ | ||
roomId, | ||
userId, | ||
username, | ||
logger, | ||
}); | ||
|
||
// Send heartbeats every 10 seconds | ||
useHeartbeat({ | ||
roomId, | ||
userId, | ||
logger, | ||
}); | ||
|
||
return ( | ||
<> | ||
<Table roomId={roomId} userId={userId} logger={logger} /> | ||
<Interactions | ||
roomId={roomId} | ||
roomReadable={roomReadable} | ||
userId={userId} | ||
logger={logger} | ||
/> | ||
</> | ||
); | ||
}; |
Oops, something went wrong.