diff options
Diffstat (limited to 'engine/src')
3 files changed, 21 insertions, 1 deletions
diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessage.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessage.kt index 689a57c..82cff37 100644 --- a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessage.kt +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/PluginMessage.kt @@ -93,6 +93,8 @@ sealed interface PluginMessage { * @property targetName Target player name * @property message Message content (romaji-converted if applicable) * @property timestamp Message timestamp (milliseconds since epoch) + * @property senderWorld Name of the world the sender is in; empty when relayed by a + * pre-1.0.2 peer */ @Serializable data class DirectMessageRelay( @@ -104,6 +106,7 @@ sealed interface PluginMessage { val targetName: String, val message: String, val timestamp: Long = System.currentTimeMillis(), + val senderWorld: String = "", ) : PluginMessage /** diff --git a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/ProtocolVersion.kt b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/ProtocolVersion.kt index 6585c86..cdf17e7 100644 --- a/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/ProtocolVersion.kt +++ b/engine/src/main/kotlin/dev/m1sk9/lunaticChat/engine/protocol/ProtocolVersion.kt @@ -33,7 +33,7 @@ package dev.m1sk9.lunaticChat.engine.protocol object ProtocolVersion { const val MAJOR = 1 const val MINOR = 0 - const val PATCH = 1 + const val PATCH = 2 /** * Minimum MINOR version this build can interoperate with (same MAJOR). 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 |
