|
|
|
@ -1,5 +1,12 @@ |
|
|
|
|
package org.openrs2.protocol |
|
|
|
|
|
|
|
|
|
import org.openrs2.protocol.login.ClientOutOfDateCodec |
|
|
|
|
import org.openrs2.protocol.login.InitJaggrabConnectionCodec |
|
|
|
|
import org.openrs2.protocol.login.InitJs5RemoteConnectionCodec |
|
|
|
|
import org.openrs2.protocol.login.IpLimitCodec |
|
|
|
|
import org.openrs2.protocol.login.Js5OkCodec |
|
|
|
|
import org.openrs2.protocol.login.ServerFullCodec |
|
|
|
|
|
|
|
|
|
public class Protocol(vararg codecs: PacketCodec<*>) { |
|
|
|
|
private val decoders = arrayOfNulls<PacketCodec<*>>(256) |
|
|
|
|
private val encoders = codecs.associateBy(PacketCodec<*>::type) |
|
|
|
@ -19,4 +26,17 @@ public class Protocol(vararg codecs: PacketCodec<*>) { |
|
|
|
|
public fun <T : Packet> getEncoder(type: Class<T>): PacketCodec<T>? { |
|
|
|
|
return encoders[type] as PacketCodec<T>? |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public companion object { |
|
|
|
|
public val LOGIN_UPSTREAM: Protocol = Protocol( |
|
|
|
|
InitJs5RemoteConnectionCodec, |
|
|
|
|
InitJaggrabConnectionCodec |
|
|
|
|
) |
|
|
|
|
public val LOGIN_DOWNSTREAM: Protocol = Protocol( |
|
|
|
|
Js5OkCodec, |
|
|
|
|
ClientOutOfDateCodec, |
|
|
|
|
ServerFullCodec, |
|
|
|
|
IpLimitCodec |
|
|
|
|
) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|