Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

Commit

Permalink
Update Receive.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
Itsusinn authored Oct 3, 2023
1 parent 9a8eda4 commit a161634
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions src/main/kotlin/handlers/Receive.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,21 @@ object Receive {
suspend fun packetHandler(pkt: Packet): Result<ControlFlow<Packet, Unit>> = withCatch(Plugin.coroutineContext) fn@{
Logger.info { "Receive msg from ${pkt.roomId}" }
if (pkt.ctl != null) {
Logger.info { "Ignoring control packet" }
return@fn ControlFlow.Continue(Unit)
}
val it = pkt.decrypt()
.onFailure {
Logger.warn { "数据解密失败" }
Logger.warn { "Failed to decrypt packet" }
}
.getOrThrow()
when (it) {
is Either.Left -> {
val futs = arrayListOf<Deferred<Result<Unit>>>()
for (target in Config.targetId(pkt.roomId) ?: return@fn ControlFlow.Break(pkt)) {
if (!it.value.from.contentEquals(target.toByteArray())) {
futs += async {
msgHandler(it.value, target, "mesagisto").onFailure { e -> Logger.error(e) }
}
msgHandler(it.value, target, "mesagisto").onFailure { e -> Logger.error(e) }
}
}
futs.joinAll()
}
is Either.Right -> {
when (it.value) {
Expand Down

0 comments on commit a161634

Please sign in to comment.