igneous-labs / telegram-space

https://telegram-space.vercel.app
2 stars 0 forks source link

Integration: receive chat message from chatapp and display speech bubble #34

Open f8122dac91 opened 1 year ago

billythedummy commented 1 year ago

2 types of messages host window -> client window:

billythedummy commented 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.

f8122dac91 commented 1 year ago

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:

f8122dac91 commented 1 year ago

After 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.

f8122dac91 commented 1 year ago

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