From 7b4f2903fd12ba6568c534c8a9fcdef13a920c44 Mon Sep 17 00:00:00 2001 From: Graham Date: Wed, 23 Dec 2020 12:56:33 +0000 Subject: [PATCH] Add initial login codecs required to negotiate a JS5 connection Signed-off-by: Graham --- .../protocol/login/ClientOutOfDateCodec.kt | 8 ++++++++ .../login/InitJs5RemoteConnectionCodec.kt | 19 +++++++++++++++++++ .../openrs2/protocol/login/IpLimitCodec.kt | 8 ++++++++ .../org/openrs2/protocol/login/Js5OkCodec.kt | 8 ++++++++ .../openrs2/protocol/login/LoginRequest.kt | 7 +++++++ .../openrs2/protocol/login/LoginResponse.kt | 10 ++++++++++ .../openrs2/protocol/login/ServerFullCodec.kt | 8 ++++++++ 7 files changed, 68 insertions(+) create mode 100644 protocol/src/main/kotlin/org/openrs2/protocol/login/ClientOutOfDateCodec.kt create mode 100644 protocol/src/main/kotlin/org/openrs2/protocol/login/InitJs5RemoteConnectionCodec.kt create mode 100644 protocol/src/main/kotlin/org/openrs2/protocol/login/IpLimitCodec.kt create mode 100644 protocol/src/main/kotlin/org/openrs2/protocol/login/Js5OkCodec.kt create mode 100644 protocol/src/main/kotlin/org/openrs2/protocol/login/LoginRequest.kt create mode 100644 protocol/src/main/kotlin/org/openrs2/protocol/login/LoginResponse.kt create mode 100644 protocol/src/main/kotlin/org/openrs2/protocol/login/ServerFullCodec.kt diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/login/ClientOutOfDateCodec.kt b/protocol/src/main/kotlin/org/openrs2/protocol/login/ClientOutOfDateCodec.kt new file mode 100644 index 00000000..08c6ad3b --- /dev/null +++ b/protocol/src/main/kotlin/org/openrs2/protocol/login/ClientOutOfDateCodec.kt @@ -0,0 +1,8 @@ +package org.openrs2.protocol.login + +import org.openrs2.protocol.EmptyPacketCodec + +public object ClientOutOfDateCodec : EmptyPacketCodec( + packet = LoginResponse.ClientOutOfDate, + opcode = 6 +) diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/login/InitJs5RemoteConnectionCodec.kt b/protocol/src/main/kotlin/org/openrs2/protocol/login/InitJs5RemoteConnectionCodec.kt new file mode 100644 index 00000000..7aec2c71 --- /dev/null +++ b/protocol/src/main/kotlin/org/openrs2/protocol/login/InitJs5RemoteConnectionCodec.kt @@ -0,0 +1,19 @@ +package org.openrs2.protocol.login + +import io.netty.buffer.ByteBuf +import org.openrs2.protocol.PacketCodec + +public object InitJs5RemoteConnectionCodec : PacketCodec( + type = LoginRequest.InitJs5RemoteConnection::class.java, + opcode = 15, + length = 4 +) { + override fun decode(input: ByteBuf): LoginRequest.InitJs5RemoteConnection { + val version = input.readInt() + return LoginRequest.InitJs5RemoteConnection(version) + } + + override fun encode(input: LoginRequest.InitJs5RemoteConnection, output: ByteBuf) { + output.writeInt(input.version) + } +} diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/login/IpLimitCodec.kt b/protocol/src/main/kotlin/org/openrs2/protocol/login/IpLimitCodec.kt new file mode 100644 index 00000000..686c003a --- /dev/null +++ b/protocol/src/main/kotlin/org/openrs2/protocol/login/IpLimitCodec.kt @@ -0,0 +1,8 @@ +package org.openrs2.protocol.login + +import org.openrs2.protocol.EmptyPacketCodec + +public object IpLimitCodec : EmptyPacketCodec( + packet = LoginResponse.IpLimit, + opcode = 9 +) diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/login/Js5OkCodec.kt b/protocol/src/main/kotlin/org/openrs2/protocol/login/Js5OkCodec.kt new file mode 100644 index 00000000..3cfa4f43 --- /dev/null +++ b/protocol/src/main/kotlin/org/openrs2/protocol/login/Js5OkCodec.kt @@ -0,0 +1,8 @@ +package org.openrs2.protocol.login + +import org.openrs2.protocol.EmptyPacketCodec + +public object Js5OkCodec : EmptyPacketCodec( + packet = LoginResponse.Js5Ok, + opcode = 0 +) diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/login/LoginRequest.kt b/protocol/src/main/kotlin/org/openrs2/protocol/login/LoginRequest.kt new file mode 100644 index 00000000..16ae65bb --- /dev/null +++ b/protocol/src/main/kotlin/org/openrs2/protocol/login/LoginRequest.kt @@ -0,0 +1,7 @@ +package org.openrs2.protocol.login + +import org.openrs2.protocol.Packet + +public sealed class LoginRequest : Packet { + public class InitJs5RemoteConnection(public val version: Int) : LoginRequest() +} diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/login/LoginResponse.kt b/protocol/src/main/kotlin/org/openrs2/protocol/login/LoginResponse.kt new file mode 100644 index 00000000..2c03f481 --- /dev/null +++ b/protocol/src/main/kotlin/org/openrs2/protocol/login/LoginResponse.kt @@ -0,0 +1,10 @@ +package org.openrs2.protocol.login + +import org.openrs2.protocol.Packet + +public sealed class LoginResponse : Packet { + public object Js5Ok : LoginResponse() + public object ClientOutOfDate : LoginResponse() + public object ServerFull : LoginResponse() + public object IpLimit : LoginResponse() +} diff --git a/protocol/src/main/kotlin/org/openrs2/protocol/login/ServerFullCodec.kt b/protocol/src/main/kotlin/org/openrs2/protocol/login/ServerFullCodec.kt new file mode 100644 index 00000000..1bc4a1ab --- /dev/null +++ b/protocol/src/main/kotlin/org/openrs2/protocol/login/ServerFullCodec.kt @@ -0,0 +1,8 @@ +package org.openrs2.protocol.login + +import org.openrs2.protocol.EmptyPacketCodec + +public object ServerFullCodec : EmptyPacketCodec( + packet = LoginResponse.ServerFull, + opcode = 7 +)