diff options
| author | Sho Sakuma <me@m1sk9.dev> | 2026-09-28 23:43:14 +0900 |
|---|---|---|
| committer | Sho Sakuma <me@m1sk9.dev> | 2026-09-28 23:43:14 +0900 |
| commit | 388ae4ef14ec620e6f1fe2ce8a8ea8e3a816d10d (patch) | |
| tree | 79e79355b5e407bbd6d71b3a7010c6f4348ab261 /engine/src/test | |
| parent | a22fce70db7b43aadd8baa42e87a4430a8b1e05f (diff) | |
| download | LunaticChat-388ae4ef14ec620e6f1fe2ce8a8ea8e3a816d10d.tar.gz LunaticChat-388ae4ef14ec620e6f1fe2ce8a8ea8e3a816d10d.tar.bz2 LunaticChat-388ae4ef14ec620e6f1fe2ce8a8ea8e3a816d10d.zip | |
feat: carry the sender's world in cross-server direct messages
{world} rendered empty for a direct message from another server, which
left formats like "({world})" showing a bare pair of brackets. The relay
now carries the sender's world as an optional field, so this is a PATCH
bump (protocol 1.0.2) and either side can be updated first; an older
sender or proxy still yields an empty value.
The world is read once per message, so the sender, the spies and the
relayed copy can no longer disagree if the sender changes worlds mid-way.
Co-Authored-By: Claude <noreply@anthropic.com>
Diffstat (limited to 'engine/src/test')
| -rw-r--r-- | engine/src/test/kotlin/dev/m1sk9/lunaticChat/engine/protocol/ProtocolBackwardCompatibilityTest.kt | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/engine/src/test/kotlin/dev/m1sk9/lunaticChat/engine/protocol/ProtocolBackwardCompatibilityTest.kt b/engine/src/test/kotlin/dev/m1sk9/lunaticChat/engine/protocol/ProtocolBackwardCompatibilityTest.kt index e70edda..095ecd1 100644 --- a/engine/src/test/kotlin/dev/m1sk9/lunaticChat/engine/protocol/ProtocolBackwardCompatibilityTest.kt +++ b/engine/src/test/kotlin/dev/m1sk9/lunaticChat/engine/protocol/ProtocolBackwardCompatibilityTest.kt @@ -42,6 +42,10 @@ class ProtocolBackwardCompatibilityTest { const val PRESENCE_SNAPSHOT_V1_0_1 = """{"players":[{"playerName":"Alice","serverName":"lobby"},{"playerName":"Bob","serverName":"survival"}],"timestamp":5000}""" + + // Protocol 1.0.2 snapshots — NEVER MODIFY after commit + const val DIRECT_MESSAGE_V1_0_2 = + """{"messageId":"dm-321","sourceServerName":"survival","senderId":"00000007-0000-0000-0000-000000000000","senderName":"Sender","targetServerName":"lobby","targetName":"Recipient","message":"Hello!","timestamp":6000,"senderWorld":"world_nether"}""" } private fun buildRawMessage( @@ -162,6 +166,19 @@ class ProtocolBackwardCompatibilityTest { assertEquals("Recipient", decoded.targetName) assertEquals("Hello!", decoded.message) assertEquals(4000L, decoded.timestamp) + assertEquals("", decoded.senderWorld) + } + + @Test + fun `current codec can decode protocol 1_0_2 DirectMessageRelay`() { + val data = buildRawMessage("direct_message", DIRECT_MESSAGE_V1_0_2) + val decoded = PluginMessageCodec.decode(data) + + assertIs<PluginMessage.DirectMessageRelay>(decoded) + assertEquals("dm-321", decoded.messageId) + assertEquals("Sender", decoded.senderName) + assertEquals("Hello!", decoded.message) + assertEquals("world_nether", decoded.senderWorld) } @Test |
