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:
fiereu authored and Fiereu committed 2025-08-29 12:54:24 +00:00
1 parent 9fabe28642
commit a9bb88b246
33 files changed
+906 -86

No files matched your search

@@ -0,0 +1,28 @@
package de.fiereu.openmmo.server.game
import de.fiereu.openmmo.protocols.game.GameServerProtocol
import de.fiereu.openmmo.server.ServerBuilder
import de.fiereu.openmmo.server.config.ServerConfig
import de.fiereu.openmmo.server.config.TlsConfig
import de.fiereu.openmmo.server.game.protocol.game.GameProtocolHandler
import de.fiereu.openmmo.server.io.resource
import de.fiereu.openmmo.server.keys.KeyLoader
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
fun main() {
val serverConfig = ServerConfig(port = 7777)
val tlsConfig = TlsConfig(checksumSize = 2)
val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.Default)
val server =
ServerBuilder.create()
.withCoroutineScope(coroutineScope)
.withConfig(serverConfig)
.withTlsConfig(tlsConfig)
.withPublicKey(KeyLoader.loadPemECPublicKey(resource("game.public.pem")))
.withPrivateKey(KeyLoader.loadPemECPrivateKey(resource("game.private.pem")))
.withChannelHandlerProvider { GameProtocolHandler(GameServerProtocol(), coroutineScope) }
.build()
server.start()
}
@@ -0,0 +1,38 @@
package de.fiereu.openmmo.server.game.protocol.game
import de.fiereu.openmmo.protocols.Protocol
import de.fiereu.openmmo.protocols.game.packets.JoinGamePacket
import de.fiereu.openmmo.server.netty.handlers.ProtocolHandler
import de.fiereu.openmmo.server.protocol.PacketEvent
import io.github.oshai.kotlinlogging.KotlinLogging
import io.netty.channel.ChannelHandlerContext
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
private val log = KotlinLogging.logger {}
class GameProtocolHandler(
protocol: Protocol,
private val coroutineScope: CoroutineScope,
) : ProtocolHandler(protocol) {
override fun onActive(ctx: ChannelHandlerContext) {
log.info { "Client ${ctx.channel().remoteAddress()} connected to game server." }
}
@Suppress("unchecked_cast") // Even here i personally check every cast. i live in ur jvm >:(
override fun onPacketReceived(event: PacketEvent<*>) {
coroutineScope.launch {
when (event.packet) {
is JoinGamePacket -> onJoinGame(event as PacketEvent<JoinGamePacket>)
else -> log.warn { "Unhandled game packet type: ${event.packet::class.simpleName}" }
}
}
}
fun onJoinGame(event: PacketEvent<JoinGamePacket>) {
log.info { "Player joined the game." }
log.debug { "This is what the Game knows about you:\n${event.packet.clientInfo.values.joinToString("\n")}" }
// TODO handle player joining the game
}
}
@@ -0,0 +1 @@
server.port = 2106
Whitespace-only changes.
@@ -0,0 +1,11 @@
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="TRACE">
<appender-ref ref="STDOUT" />
</root>
</configuration>