Separate LoginResponse and Js5LoginResponse

I'm currently working on a CreateResponse class, which is even more
distinct from LoginResponse - so I've decided to separate it. For
consistency, separating the JS5 login responses seems sensible too.

Signed-off-by: Graham <gpe@openrs2.org>
master
Graham 2 years ago
parent e4b5f8b850
commit 851ef8e4e9
  1. 8
      archive/src/main/kotlin/org/openrs2/archive/cache/OsrsJs5ChannelHandler.kt
  2. 6
      archive/src/main/kotlin/org/openrs2/archive/cache/OsrsJs5ChannelInitializer.kt
  3. 6
      game/src/main/kotlin/org/openrs2/game/net/login/LoginChannelHandler.kt
  4. 11
      protocol/src/main/kotlin/org/openrs2/protocol/ProtocolModule.kt
  5. 10
      protocol/src/main/kotlin/org/openrs2/protocol/js5/downstream/Js5ClientOutOfDateCodec.kt
  6. 10
      protocol/src/main/kotlin/org/openrs2/protocol/js5/downstream/Js5IpLimitCodec.kt
  7. 10
      protocol/src/main/kotlin/org/openrs2/protocol/js5/downstream/Js5LoginResponse.kt
  8. 10
      protocol/src/main/kotlin/org/openrs2/protocol/js5/downstream/Js5OkCodec.kt
  9. 10
      protocol/src/main/kotlin/org/openrs2/protocol/js5/downstream/Js5ServerFullCodec.kt
  10. 10
      protocol/src/main/kotlin/org/openrs2/protocol/login/downstream/Js5OkCodec.kt
  11. 1
      protocol/src/main/kotlin/org/openrs2/protocol/login/downstream/LoginResponse.kt

@ -6,12 +6,12 @@ import io.netty.channel.ChannelPipeline
import org.openrs2.cache.MasterIndexFormat
import org.openrs2.protocol.Rs2Decoder
import org.openrs2.protocol.Rs2Encoder
import org.openrs2.protocol.js5.downstream.Js5LoginResponse
import org.openrs2.protocol.js5.downstream.Js5Response
import org.openrs2.protocol.js5.downstream.Js5ResponseDecoder
import org.openrs2.protocol.js5.downstream.XorDecoder
import org.openrs2.protocol.js5.upstream.Js5Request
import org.openrs2.protocol.js5.upstream.Js5RequestEncoder
import org.openrs2.protocol.login.downstream.LoginResponse
import org.openrs2.protocol.login.upstream.LoginRequest
import kotlin.coroutines.Continuation
@ -66,9 +66,9 @@ public class OsrsJs5ChannelHandler(
override fun channelRead0(ctx: ChannelHandlerContext, msg: Any) {
when (msg) {
is LoginResponse.Js5Ok -> handleOk(ctx)
is LoginResponse.ClientOutOfDate -> handleClientOutOfDate(ctx)
is LoginResponse -> throw Exception("Invalid response: $msg")
is Js5LoginResponse.Ok -> handleOk(ctx)
is Js5LoginResponse.ClientOutOfDate -> handleClientOutOfDate(ctx)
is Js5LoginResponse -> throw Exception("Invalid response: $msg")
is Js5Response -> handleResponse(ctx, msg.prefetch, msg.archive, msg.group, msg.data)
else -> throw Exception("Unknown message type: ${msg.javaClass.name}")
}

@ -6,8 +6,8 @@ import io.netty.handler.timeout.ReadTimeoutHandler
import org.openrs2.protocol.Protocol
import org.openrs2.protocol.Rs2Decoder
import org.openrs2.protocol.Rs2Encoder
import org.openrs2.protocol.login.downstream.ClientOutOfDateCodec
import org.openrs2.protocol.login.downstream.Js5OkCodec
import org.openrs2.protocol.js5.downstream.Js5ClientOutOfDateCodec
import org.openrs2.protocol.js5.downstream.Js5OkCodec
import org.openrs2.protocol.login.upstream.InitJs5RemoteConnectionCodec
public class OsrsJs5ChannelInitializer(private val handler: OsrsJs5ChannelHandler) : ChannelInitializer<Channel>() {
@ -15,7 +15,7 @@ public class OsrsJs5ChannelInitializer(private val handler: OsrsJs5ChannelHandle
ch.pipeline().addLast(
ReadTimeoutHandler(30),
Rs2Encoder(Protocol(InitJs5RemoteConnectionCodec())),
Rs2Decoder(Protocol(Js5OkCodec(), ClientOutOfDateCodec()))
Rs2Decoder(Protocol(Js5OkCodec(), Js5ClientOutOfDateCodec()))
)
ch.pipeline().addLast("handler", handler)
}

@ -20,11 +20,11 @@ import org.openrs2.protocol.Protocol
import org.openrs2.protocol.Rs2Decoder
import org.openrs2.protocol.Rs2Encoder
import org.openrs2.protocol.jaggrab.upstream.JaggrabRequestDecoder
import org.openrs2.protocol.js5.downstream.Js5LoginResponse
import org.openrs2.protocol.js5.downstream.Js5RemoteDownstream
import org.openrs2.protocol.js5.downstream.Js5ResponseEncoder
import org.openrs2.protocol.js5.downstream.XorDecoder
import org.openrs2.protocol.js5.upstream.Js5RequestDecoder
import org.openrs2.protocol.login.downstream.LoginResponse
import org.openrs2.protocol.login.upstream.LoginRequest
import org.openrs2.protocol.world.downstream.WorldListDownstream
import org.openrs2.protocol.world.downstream.WorldListResponse
@ -59,7 +59,7 @@ public class LoginChannelHandler @Inject constructor(
encoder.protocol = js5RemoteDownstreamProtocol
if (msg.build != BUILD) {
ctx.write(LoginResponse.ClientOutOfDate).addListener(ChannelFutureListener.CLOSE)
ctx.write(Js5LoginResponse.ClientOutOfDate).addListener(ChannelFutureListener.CLOSE)
return
}
@ -71,7 +71,7 @@ public class LoginChannelHandler @Inject constructor(
)
ctx.pipeline().remove(Rs2Decoder::class.java)
ctx.write(LoginResponse.Js5Ok).addListener { future ->
ctx.write(Js5LoginResponse.Ok).addListener { future ->
if (future.isSuccess) {
ctx.pipeline().remove(encoder)
ctx.pipeline().remove(this)

@ -6,10 +6,13 @@ import com.google.inject.TypeLiteral
import com.google.inject.multibindings.Multibinder
import org.openrs2.buffer.BufferModule
import org.openrs2.crypto.CryptoModule
import org.openrs2.protocol.js5.downstream.Js5ClientOutOfDateCodec
import org.openrs2.protocol.js5.downstream.Js5IpLimitCodec
import org.openrs2.protocol.js5.downstream.Js5OkCodec
import org.openrs2.protocol.js5.downstream.Js5RemoteDownstream
import org.openrs2.protocol.js5.downstream.Js5ServerFullCodec
import org.openrs2.protocol.login.downstream.ClientOutOfDateCodec
import org.openrs2.protocol.login.downstream.IpLimitCodec
import org.openrs2.protocol.login.downstream.Js5OkCodec
import org.openrs2.protocol.login.downstream.LoginDownstream
import org.openrs2.protocol.login.downstream.ServerFullCodec
import org.openrs2.protocol.login.upstream.CheckWorldSuitabilityCodec
@ -33,9 +36,9 @@ public object ProtocolModule : AbstractModule() {
bindProtocol(
Js5RemoteDownstream::class.java,
Js5OkCodec::class.java,
ClientOutOfDateCodec::class.java,
ServerFullCodec::class.java,
IpLimitCodec::class.java
Js5ClientOutOfDateCodec::class.java,
Js5ServerFullCodec::class.java,
Js5IpLimitCodec::class.java
)
bindProtocol(

@ -0,0 +1,10 @@
package org.openrs2.protocol.js5.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class Js5ClientOutOfDateCodec : EmptyPacketCodec<Js5LoginResponse.ClientOutOfDate>(
packet = Js5LoginResponse.ClientOutOfDate,
opcode = 6
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.js5.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class Js5IpLimitCodec : EmptyPacketCodec<Js5LoginResponse.IpLimit>(
packet = Js5LoginResponse.IpLimit,
opcode = 9
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.js5.downstream
import org.openrs2.protocol.Packet
public sealed class Js5LoginResponse : Packet {
public object Ok : Js5LoginResponse()
public object ClientOutOfDate : Js5LoginResponse()
public object ServerFull : Js5LoginResponse()
public object IpLimit : Js5LoginResponse()
}

@ -0,0 +1,10 @@
package org.openrs2.protocol.js5.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class Js5OkCodec : EmptyPacketCodec<Js5LoginResponse.Ok>(
packet = Js5LoginResponse.Ok,
opcode = 0
)

@ -0,0 +1,10 @@
package org.openrs2.protocol.js5.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class Js5ServerFullCodec : EmptyPacketCodec<Js5LoginResponse.ServerFull>(
packet = Js5LoginResponse.ServerFull,
opcode = 7
)

@ -1,10 +0,0 @@
package org.openrs2.protocol.login.downstream
import org.openrs2.protocol.EmptyPacketCodec
import javax.inject.Singleton
@Singleton
public class Js5OkCodec : EmptyPacketCodec<LoginResponse.Js5Ok>(
packet = LoginResponse.Js5Ok,
opcode = 0
)

@ -3,7 +3,6 @@ package org.openrs2.protocol.login.downstream
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()

Loading…
Cancel
Save