mirror of
https://github.com/djdevin/recflare.git
synced 2026-09-08 22:51:30 -07:00
testing generic deploy
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
# match
|
||||
|
||||
Matchmaking Worker served at `match.rec.djdevin.net`. A Hono app ported from the
|
||||
C# `MatchmakingController`. EF Core (`AppDbContext`) queries are stubbed for now
|
||||
— no real bindings yet.
|
||||
Matchmaking Worker served on the `match` subdomain. A Hono app for matchmaking.
|
||||
Database queries are stubbed for now — no real bindings yet.
|
||||
|
||||
## Behavior
|
||||
|
||||
@@ -10,7 +9,7 @@ C# `MatchmakingController`. EF Core (`AppDbContext`) queries are stubbed for now
|
||||
Bearer JWT issued by the `auth` worker (same dev secret, see `src/jwt.ts`) and
|
||||
401 when it's missing/invalid.
|
||||
- **`GET /player`** always returns the inlined `JSON/getplayer.json` default
|
||||
(the C# fell back to that file when the account/room instance wasn't found).
|
||||
(falls back to that file when the account/room instance isn't found).
|
||||
- **`POST /goto/none`** returns the static offline-dorm instance with a fresh
|
||||
`photonRoomId`.
|
||||
- **`POST /goto/room/:room`** synthesizes the room-instance response (no Rooms
|
||||
@@ -19,7 +18,7 @@ C# `MatchmakingController`. EF Core (`AppDbContext`) queries are stubbed for now
|
||||
- **`POST /player/heartbeat`** echoes the posted heartbeat fields; `roomInstance`
|
||||
is always null and `isOnline` false until there's a DB binding.
|
||||
- **`/player/login`, `/player/statusvisibility`, `/roominstance/:id/reportjoinresult`**
|
||||
return empty 200s, as in the source.
|
||||
return empty 200s.
|
||||
|
||||
## TODO before production
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Minimal HS256 JWT validation, mirroring the C# `JwtTokenService.ValidateAndGetAccountId`.
|
||||
* Minimal HS256 JWT validation.
|
||||
*
|
||||
* Uses the same placeholder dev secret as the `auth` worker (`apps/auth/src/jwt.ts`).
|
||||
* Swap both for a shared secret binding before this is used for anything real.
|
||||
|
||||
+13
-16
@@ -11,17 +11,16 @@ import type { App } from './context'
|
||||
import type { Room } from './rooms-db'
|
||||
|
||||
/**
|
||||
* Ported from the C# `MatchmakingController`. Endpoints the C# backs with EF Core
|
||||
* (`AppDbContext`) are stubbed here — there's no DB binding yet, so room/player
|
||||
* lookups fall back to the same defaults the C# uses when nothing is found.
|
||||
* The matchmaking surface. Database-backed endpoints are stubbed here — there's
|
||||
* no DB binding yet, so room/player lookups fall back to default values when
|
||||
* nothing is found.
|
||||
*
|
||||
* Auth-gated routes still validate the Bearer JWT issued by the `auth` worker.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default `/player` payload. The C# serves this from `JSON/getplayer.json`
|
||||
* whenever the `id` is missing/invalid or the account isn't found; Workers have
|
||||
* no filesystem so it's inlined here.
|
||||
* Default `/player` payload, served whenever the `id` is missing/invalid or the
|
||||
* account isn't found. Inlined here (Workers have no filesystem).
|
||||
*/
|
||||
const DEFAULT_GET_PLAYER = [
|
||||
{
|
||||
@@ -48,7 +47,7 @@ interface HeartbeatRequest {
|
||||
|
||||
/**
|
||||
* Resolve the account id from a Bearer token, mirroring the repeated
|
||||
* auth-header check in the C#. Returns `null` when the header is missing,
|
||||
* auth-header check. Returns `null` when the header is missing,
|
||||
* the token is invalid, or the `sub` claim isn't an integer.
|
||||
*/
|
||||
async function authedId(c: Context<App>): Promise<number | null> {
|
||||
@@ -89,10 +88,9 @@ interface Presence {
|
||||
const PRESENCE_TTL = 900
|
||||
|
||||
/**
|
||||
* Game build version reported in presence. Like the reference servers (FemRec
|
||||
* `ServerConfig.GameVersion`, 2025 `HeartbeatDB`), this is a server-side
|
||||
* constant — the client doesn't supply it, and an empty value breaks the
|
||||
* client's presence/version handling. Matches our target 2023 client build.
|
||||
* Game build version reported in presence. This is a server-side constant — the
|
||||
* client doesn't supply it, and an empty value breaks the client's
|
||||
* presence/version handling. Matches our target 2023 client build.
|
||||
*/
|
||||
const GAME_VERSION = '20230302'
|
||||
|
||||
@@ -256,8 +254,8 @@ const app = new Hono<App>()
|
||||
.post('/player/logout', (c) => c.body(null, 200))
|
||||
|
||||
.get('/player', async (c) => {
|
||||
// Returns each requested player's presence. The C# reads the `id` query
|
||||
// param(s); with none it serves the static getplayer.json default.
|
||||
// Returns each requested player's presence. Reads the `id` query param(s);
|
||||
// with none it serves the static getplayer.json default.
|
||||
const ids = c.req
|
||||
.queries('id')
|
||||
?.flatMap((v) => v.split(','))
|
||||
@@ -363,8 +361,7 @@ const app = new Hono<App>()
|
||||
// isn't swallowed by the auth-gated matchmake handler.
|
||||
.post('/matchmake/none', async (c) => {
|
||||
const id = await authedId(c)
|
||||
// FemRec (our 2023-client target) returns the player's *current* heartbeat
|
||||
// here rather than forcing the dorm (the 2025 server's behavior we'd copied).
|
||||
// Return the player's *current* heartbeat here rather than forcing the dorm.
|
||||
// Orientation is a solo room the client establishes via matchmake/none; if we
|
||||
// force the dorm, the new player is warped out of Orientation within seconds.
|
||||
// So: preserve existing presence; only fall back to the offline dorm when the
|
||||
@@ -396,7 +393,7 @@ const app = new Hono<App>()
|
||||
|
||||
const room = c.req.param('room')
|
||||
const joinMode = await readJoinMode(c)
|
||||
// The C# dorm check here is "dorm" (goto/room uses "dormroom").
|
||||
// The dorm check here is "dorm" (goto/room uses "dormroom").
|
||||
const instance =
|
||||
room.toLowerCase() === 'dorm'
|
||||
? dormRoomInstance()
|
||||
|
||||
@@ -10,7 +10,7 @@ declare module 'cloudflare:test' {
|
||||
interface ProvidedEnv extends Env {}
|
||||
}
|
||||
|
||||
const ORIGIN = 'https://match.rec.djdevin.net'
|
||||
const ORIGIN = 'https://example.com'
|
||||
|
||||
// Matchmaking into a room resolves its real scene from the shared rec-rooms D1.
|
||||
// Seed the schema + a couple of rooms (matching the rooms worker's migration).
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"compatibility_flags": ["nodejs_compat"],
|
||||
"routes": [
|
||||
{
|
||||
"pattern": "match.rec.djdevin.net",
|
||||
"pattern": "match.rec.example.com",
|
||||
"custom_domain": true
|
||||
}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user