Relocate 30 non-essential .md files (investigation notes, fix summaries, implementation details, status reports) from the project root into docs/ to reduce clutter. Core operational docs (README, quickstart guides, configuration references) remain in the root. Co-authored-by: Cursor <cursoragent@cursor.com>
2.2 KiB
2.2 KiB
Kosmi WebSocket Protocol Findings
Key Discoveries from Browser Monitoring
Room ID Format
- Browser uses
"@hyperspaceout"(WITH @ symbol) for all operations - Our script was using
"hyperspaceout"(WITHOUT @) - this is whyjoinRoomfailed withROOM_NOT_FOUND
Page Load Sequence
The browser does NOT call joinRoom mutation. Instead, it:
- Connects to WebSocket at
wss://engine.kosmi.io/gql-ws - Sends
connection_initwith auth token - Immediately starts subscribing to various topics:
OnNewMessage(roomId: "@hyperspaceout")- for chat messagesOnLinkedMembers(roomId: "@hyperspaceout")- for room membersOnMediaPlayerUpdateState(roomId: "@hyperspaceout")- for media playerOnMediaPlayerUpdateSubtitles(roomId: "@hyperspaceout")- for subtitlesOnMediasoupUpdate(roomId: "@hyperspaceout")- for WebRTCOnRoomUpdate(roomId: "@hyperspaceout")- for room stateOnMessageReadersUpdate(roomId: "@hyperspaceout")- for read receipts
Sending Messages
To send a message, the browser likely uses:
mutation SendMessage($body: String!, $roomId: String!) {
sendMessage(body: $body, roomId: $roomId) {
ok
}
}
With variables:
{
"body": "message text",
"roomId": "@hyperspaceout"
}
Authentication
The connection_init payload includes:
token: JWT fromanonLoginmutationua: Base64-encoded User-Agentv: App version "4364"r: Empty string for anonymous users
Next Steps
- ✅ Use
"@hyperspaceout"(with @) instead of"hyperspaceout" - ✅ Skip the
joinRoommutation entirely - ✅ Just send the
sendMessagemutation directly afterconnection_ack - Test if the message appears in chat
Important Note
The sendMessage mutation returns { ok: true } even when the message doesn't appear in chat. This suggests that:
- The mutation succeeds on the server side
- But the message might be filtered or not broadcast
- Possibly because we're not "subscribed" to the room's message feed
- Or because anonymous users have restrictions
We should subscribe to OnNewMessage to see if our sent messages come back through the subscription.