redone player/user structure. player can only be in one lobby; realtime with trpc subscriptions and redis

This commit is contained in:
2025-03-29 19:10:07 +01:00
parent a00116a61d
commit 2db3af2dfc
38 changed files with 819 additions and 423 deletions
+22 -9
View File
@@ -1,7 +1,12 @@
"use client";
import { QueryClientProvider, type QueryClient } from "@tanstack/react-query";
import { httpBatchStreamLink, loggerLink } from "@trpc/client";
import {
httpBatchStreamLink,
httpSubscriptionLink,
loggerLink,
splitLink,
} from "@trpc/client";
import { createTRPCReact } from "@trpc/react-query";
import { type inferRouterInputs, type inferRouterOutputs } from "@trpc/server";
import { useState } from "react";
@@ -50,14 +55,22 @@ export function TRPCReactProvider(props: { children: React.ReactNode }) {
process.env.NODE_ENV === "development" ||
(op.direction === "down" && op.result instanceof Error),
}),
httpBatchStreamLink({
transformer: SuperJSON,
url: getBaseUrl() + "/api/trpc",
headers: () => {
const headers = new Headers();
headers.set("x-trpc-source", "nextjs-react");
return headers;
},
splitLink({
// uses the httpSubscriptionLink for subscriptions
condition: (op) => op.type === "subscription",
true: httpSubscriptionLink({
transformer: SuperJSON,
url: `${getBaseUrl()}/api/trpc`,
}),
false: httpBatchStreamLink({
transformer: SuperJSON,
url: `${getBaseUrl()}/api/trpc`,
headers: () => {
const headers = new Headers();
headers.set("x-trpc-source", "nextjs-react");
return headers;
},
}),
}),
],
}),