Initial work on multi-server bridge from a while back.

This commit is contained in:
Liv 2022-07-09 15:56:46 -07:00
parent 5d7bf94e5c
commit e05d6355e6
No known key found for this signature in database
GPG Key ID: 9743CEF10935949A
7 changed files with 68 additions and 6 deletions

View File

@ -1,6 +1,6 @@
plugins {
`kotlin-dsl`
kotlin("plugin.serialization") version "1.5.31"
kotlin("plugin.serialization") version "1.6.21"
}
repositories {
@ -8,10 +8,10 @@ repositories {
}
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10")
implementation("org.jetbrains.kotlin:kotlin-serialization:1.6.10")
implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.1")
implementation("com.google.code.gson:gson:2.8.9")
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.21")
implementation("org.jetbrains.kotlin:kotlin-serialization:1.6.21")
implementation("gradle.plugin.com.github.johnrengelman:shadow:7.1.2")
implementation("com.google.code.gson:gson:2.9.0")
implementation("org.bouncycastle:bcprov-jdk15on:1.70")
}

View File

@ -2,6 +2,7 @@ dependencies {
implementation("net.dv8tion:JDA:5.0.0-alpha.2") {
exclude(module = "opus-java")
}
implementation("com.rabbitmq:amqp-client:5.14.2")
compileOnly(project(":foundation-core"))
}

View File

@ -0,0 +1,11 @@
package cloud.kubelet.foundation.bifrost
import io.papermc.paper.event.player.AsyncChatEvent
import org.bukkit.event.player.PlayerJoinEvent
import org.bukkit.event.player.PlayerQuitEvent
interface EventHandler {
fun onPlayerJoin(e: PlayerJoinEvent)
fun onPlayerQuit(e: PlayerQuitEvent)
fun onChat(e: AsyncChatEvent)
}

View File

@ -0,0 +1,26 @@
package cloud.kubelet.foundation.bifrost
import cloud.kubelet.foundation.bifrost.model.BifrostMessageQueueConfig
import cloud.kubelet.foundation.bifrost.model.BifrostMultiConfig
import com.rabbitmq.client.Connection
import com.rabbitmq.client.ConnectionFactory
import io.papermc.paper.event.player.AsyncChatEvent
class MultiServerEventHandler(config: BifrostMultiConfig) : EventHandler {
private val bus = buildConnection(config.messageQueue)
private val channel = bus.createChannel()
init {
channel.queueDeclare(config.messageQueue.queueName, false, false, false, emptyMap())
}
override fun onChat(e: AsyncChatEvent) {
}
private companion object {
fun buildConnection(config: BifrostMessageQueueConfig): Connection = ConnectionFactory().apply {
host = config.host
port = config.port
}.newConnection()
}
}

View File

@ -0,0 +1,19 @@
package cloud.kubelet.foundation.bifrost.model
import kotlinx.serialization.Serializable
@Serializable
data class BifrostMultiConfig(
val messageQueue: BifrostMessageQueueConfig,
)
@Serializable
data class BifrostMessageQueueConfig(
val host: String = "localhost",
val port: Int = 5672,
/**
* Name of the RabbitMQ queue
*/
val queueName: String = "bifrost",
)

View File

@ -0,0 +1,5 @@
# Configuration for the Bifrost multi-server chat bridge.
messageQueue:
host: localhost

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists