Skip to content

Commit

Permalink
feat: enable reconnect on frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
edalholt committed Oct 1, 2023
1 parent 3d940d5 commit 2d82a6e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
9 changes: 8 additions & 1 deletion frontend/src/components/EditAssembly.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ export function EditAssembly(state: { group: UserDataGroupType }) {
const [accordionActiveTabs, setAccordionActiveTabs] = useState<string[]>([]);

const { lastMessage, sendJsonMessage } = useWebSocket(
import.meta.env.VITE_SOCKET_URL + "/organizer"
import.meta.env.VITE_SOCKET_URL + "/organizer",
{
//Will attempt to reconnect on all close events, such as server shutting down
shouldReconnect: () => true,
// Try to reconnect 300 times before giving up.
// Also possible to change interval (default is 5000ms)
reconnectAttempts: 300,
}
);

// Request access to live assembly data for the given group when component is mounted.
Expand Down
11 changes: 9 additions & 2 deletions frontend/src/pages/AssemblyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { LimitedVoteType } from "../types/votes";
import { getUserData } from "../services/organizer";
import { NotFound } from "./NotFound";

export function AssemblyLobby() {
export function AssemblyLobxby() {
let navigate = useNavigate();
const { groupSlug } = useParams() as { groupSlug: string };
const [groupName, setGroupName] = useState<string | undefined>(undefined);
Expand All @@ -26,7 +26,14 @@ export function AssemblyLobby() {
>(undefined);
const [voted, setVoted] = useState<boolean>(false);
const { lastMessage } = useWebSocket(
import.meta.env.VITE_SOCKET_URL + "/lobby"
import.meta.env.VITE_SOCKET_URL + "/lobby",
{
//Will attempt to reconnect on all close events, such as server shutting down
shouldReconnect: () => true,
// Try to reconnect 300 times before giving up.
// Also possible to change interval (default is 5000ms)
reconnectAttempts: 300,
}
);
const { checkedIn, setCheckedIn } = useContext(
checkedInState
Expand Down

0 comments on commit 2d82a6e

Please sign in to comment.