clean up some social endpoints, sockets not working yet

This commit is contained in:
Devin Zuczek
2026-07-16 13:15:06 -04:00
parent 710031b2a3
commit 2ff6526834
7 changed files with 210 additions and 51 deletions
+5
View File
@@ -426,6 +426,11 @@ const app = new Hono<App>()
return c.body(null, 200)
})
// Fire-and-forget disconnect notification (form body `PlayerId`/`RoomInstanceId`).
// The client posts this when it drops a room; we don't act on it — presence is
// cleared by logout and otherwise expires on its own TTL — so just ack with 200.
.post('/player/notifydisconnect', (c) => c.body(null, 200))
.get('/player', async (c) => {
// Returns each requested player's presence. Reads the `id` query param(s);
// with none it serves the static getplayer.json default.
@@ -150,6 +150,15 @@ describe('public endpoints', () => {
expect(await res.json()).toEqual({ errorCode: 0 })
})
test('POST /player/notifydisconnect returns 200', async () => {
const res = await exports.default.fetch(`${ORIGIN}/player/notifydisconnect`, {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: 'PlayerId=155&RoomInstanceId=1000001',
})
expect(res.status).toBe(200)
})
test('GET /player?id=N synthesizes a player payload for that id', async () => {
const res = await exports.default.fetch(`${ORIGIN}/player?id=99`)
expect(res.status).toBe(200)