Open f8122dac91 opened 1 year ago
All message formats passed across MessageChannel shall be stringified JSON. (note: MessageChannel allows a variety of types to be passed including byte arrays but we'll keep it to JSON for simplicity)
Initialization
schema:{ matrix_id: string }
Message
schema:{ matrix_id: string, body: string }
where matrix_id
is the sender of the message, body
is matrixEvent.getContent().body
Note that matrixEvent.getContent().body
may be undefined
, and that matrixEvent.getContent()
have other rich fields such as formatted_body
and m.relates_to
that we aren't using now but we may use in the future
No type discriminator needed for now since the messages are sent at different times.
WIP
The game server assigns each game client a client_id: u16
. Now in order to display incoming chat messages from chat client inside the game client, it needs to know how to map chat message's matrix_id: String
to client_id
to identify the RemotePlayer
node which is identified by its client_id
.
For this:
Character
scene now has a matrix_id: String
fieldPlayer.matrix_id
initialization, game client will send PlayerChatUserId(Vec<u8>)
client -> server messageclient_id
-> chat_user_id
(in this case matrix_id
is the choice of chat_user_id
)Player
entering an Instance
game server will look at the Instance
the client is entering, and sync the chat_user_id
by:
chat_user_id
of the newly connected client to everybody in the instancechat_user_id
of everyone in the instance to the newly connected clientAfter discussion, we realized matrix id syncing having a separate message becomes messy and complex really quickly. For now we'll just rely on world sync to relay matrix id to each client in an instance. We know this will possibly increase the payload size by the factor of the instance population and the world sync rate, but we'll worry about that later when it becomes a bottleneck.
With this implementation we can now relay matrix id to server and get it back on world sync time: https://github.com/igneous-labs/telegram-space/pull/38#issuecomment-1433132755
NOTE: this is a temporary solution, we will get this resolved later when we have problems or when we refactor networking. Opening a backlog issue to track this: #39
2 types of messages host window -> client window: