dev_minimal_login (#7)
### Summary Implement minimal login flow without any authentication. Implement basic game server module with JoingGamePacket implemented. ### Type of Change New feature (non-breaking change which adds functionality) ### Affected Modules - [x] common/ - [ ] protocol/ - [ ] protocol.tls/ - [x] protocol.login/ - [ ] server/ - [x] server.login/ - [ ] keys/ - [ ] patcher/ - [ ] buildSrc/ ### Additional Notes _No response_ Reviewed-on: https://forge.fiereu.de/OpenMMO/OpenMMO/pulls/7 Co-authored-by: fiereu <contact@fiereu.de> Co-committed-by: fiereu <contact@fiereu.de>
This commit is contained in:
1 parent
9fabe28642
commit
a9bb88b246
33 files changed
+906
-86
No files matched your search
@@ -47,12 +47,21 @@ fun ByteBuf.readIpLE(): IPAddress {
|
||||
}
|
||||
|
||||
fun ByteBuf.writeIpLE(ipAddress: IPAddress) {
|
||||
if (ipAddress is IPv4Address) {
|
||||
writeByte(4)
|
||||
writeIntLE(ipAddress.toInt())
|
||||
} else {
|
||||
writeByte(6)
|
||||
writeBytes(ipAddress.toArray())
|
||||
when (ipAddress) {
|
||||
is IPv4Address -> {
|
||||
writeByte(4)
|
||||
writeIntLE(ipAddress.toInt())
|
||||
}
|
||||
|
||||
is IPv6Address -> {
|
||||
writeByte(6)
|
||||
writeLongLE(ipAddress.upper)
|
||||
writeLongLE(ipAddress.lower)
|
||||
}
|
||||
|
||||
else -> {
|
||||
throw IllegalArgumentException("Unsupported IP address type: ${ipAddress::class}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package de.fiereu.openmmo.protocols
|
||||
import io.github.oshai.kotlinlogging.KotlinLogging
|
||||
import io.netty.buffer.ByteBuf
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.reflect.jvm.jvmErasure
|
||||
|
||||
/** Value class wrapping a UByte to represent an opcode. */
|
||||
@JvmInline
|
||||
@@ -49,9 +50,7 @@ abstract class Protocol {
|
||||
|
||||
abstract val async: Boolean
|
||||
|
||||
fun getOpcode(dataClass: KClass<*>): Opcode? {
|
||||
return dataClassToOpcode[dataClass]
|
||||
}
|
||||
fun getOpcode(dataClass: KClass<*>): Opcode? = dataClassToOpcode[dataClass]
|
||||
|
||||
fun <T : Any> registerIncoming(opcode: Opcode, deserializer: PacketDeserializer<T>) {
|
||||
log.debug {
|
||||
@@ -63,13 +62,17 @@ abstract class Protocol {
|
||||
|
||||
fun <T : Any> registerOutgoing(
|
||||
opcode: Opcode,
|
||||
dataClass: KClass<T>,
|
||||
serializer: PacketSerializer<T>,
|
||||
dataClass: KClass<T>,
|
||||
) {
|
||||
log.debug {
|
||||
"Registering outgoing packet: opcode=$opcode, serializer=${serializer::class.simpleName}"
|
||||
}
|
||||
|
||||
if (dataClassToOpcode.containsKey(dataClass)) {
|
||||
// Better to fail fast here than to have hard to debug issues later
|
||||
error("Data class ${dataClass.simpleName} is already registered with an opcode!")
|
||||
}
|
||||
dataClassToOpcode[dataClass] = opcode
|
||||
outgoingPacketRegistry.put(opcode, serializer)
|
||||
}
|
||||
@@ -93,8 +96,8 @@ fun <T : Any> Protocol.incomingPacket(opcode: UByte, deserializer: PacketDeseria
|
||||
|
||||
fun <T : Any> Protocol.outgoingPacket(
|
||||
opcode: UByte,
|
||||
dataClass: KClass<T>,
|
||||
serializer: PacketSerializer<T>
|
||||
serializer: PacketSerializer<T>,
|
||||
dataClass: KClass<T>
|
||||
) {
|
||||
this.registerOutgoing(Opcode(opcode), dataClass, serializer)
|
||||
this.registerOutgoing(Opcode(opcode), serializer, dataClass)
|
||||
}
|
||||
Reference in new issue
Block a user