Move BdhSession from package context to components

This commit is contained in:
Him188 2021-07-28 10:51:51 +08:00
parent 3b5ec941b3
commit 4f1a22cd20
6 changed files with 17 additions and 33 deletions

View File

@ -18,7 +18,7 @@ import net.mamoe.mirai.internal.QQAndroidBot
import net.mamoe.mirai.internal.message.OfflineFriendImage
import net.mamoe.mirai.internal.message.contextualBugReportException
import net.mamoe.mirai.internal.message.getImageType
import net.mamoe.mirai.internal.network.context.BdhSession
import net.mamoe.mirai.internal.network.components.BdhSession
import net.mamoe.mirai.internal.network.highway.ChannelKind
import net.mamoe.mirai.internal.network.highway.Highway
import net.mamoe.mirai.internal.network.highway.ResourceKind.PRIVATE_IMAGE

View File

@ -24,7 +24,7 @@ import net.mamoe.mirai.internal.QQAndroidBot
import net.mamoe.mirai.internal.contact.announcement.AnnouncementsImpl
import net.mamoe.mirai.internal.contact.info.MemberInfoImpl
import net.mamoe.mirai.internal.message.OfflineGroupImage
import net.mamoe.mirai.internal.network.context.BdhSession
import net.mamoe.mirai.internal.network.components.BdhSession
import net.mamoe.mirai.internal.network.handler.NetworkHandler
import net.mamoe.mirai.internal.network.handler.logger
import net.mamoe.mirai.internal.network.highway.ChannelKind

View File

@ -12,19 +12,17 @@ package net.mamoe.mirai.internal.network.components
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.serialization.KSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.builtins.SetSerializer
import net.mamoe.mirai.internal.network.JsonForCache
import net.mamoe.mirai.internal.network.ProtoBufForCache
import net.mamoe.mirai.internal.network.component.ComponentKey
import net.mamoe.mirai.internal.network.component.ComponentStorage
import net.mamoe.mirai.internal.network.context.BdhSession
import net.mamoe.mirai.internal.utils.actualCacheDir
import net.mamoe.mirai.utils.BotConfiguration
import net.mamoe.mirai.utils.MiraiLogger
import java.io.File
private val ServerListSerializer: KSerializer<Set<ServerAddress>> =
SetSerializer(ServerAddress.serializer())
import java.util.concurrent.CopyOnWriteArraySet
internal interface BdhSessionSyncer {
val bdhSession: CompletableDeferred<BdhSession>
@ -43,6 +41,17 @@ internal interface BdhSessionSyncer {
companion object : ComponentKey<BdhSessionSyncer>
}
@Serializable
internal class BdhSession(
val sigSession: ByteArray,
val sessionKey: ByteArray,
var ssoAddresses: MutableSet<Pair<Int, Int>> = CopyOnWriteArraySet(),
var otherAddresses: MutableSet<Pair<Int, Int>> = CopyOnWriteArraySet(),
)
private val ServerListSerializer: KSerializer<Set<ServerAddress>> =
SetSerializer(ServerAddress.serializer())
@OptIn(ExperimentalCoroutinesApi::class)
internal class BdhSessionSyncerImpl(
private val configuration: BotConfiguration,

View File

@ -1,21 +0,0 @@
/*
* Copyright 2019-2021 Mamoe Technologies and contributors.
*
* 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 可以在以下链接找到该许可证.
* Use of this source code is governed by the GNU AGPLv3 license that can be found through the following link.
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
package net.mamoe.mirai.internal.network.context
import kotlinx.serialization.Serializable
import java.util.concurrent.CopyOnWriteArraySet
@Serializable
internal class BdhSession(
val sigSession: ByteArray,
val sessionKey: ByteArray,
var ssoAddresses: MutableSet<Pair<Int, Int>> = CopyOnWriteArraySet(),
var otherAddresses: MutableSet<Pair<Int, Int>> = CopyOnWriteArraySet(),
)

View File

@ -22,8 +22,8 @@ import kotlinx.io.core.writeFully
import net.mamoe.mirai.internal.QQAndroidBot
import net.mamoe.mirai.internal.asQQAndroidBot
import net.mamoe.mirai.internal.network.QQAndroidClient
import net.mamoe.mirai.internal.network.components.BdhSession
import net.mamoe.mirai.internal.network.components.BdhSessionSyncer
import net.mamoe.mirai.internal.network.context.BdhSession
import net.mamoe.mirai.internal.network.handler.logger
import net.mamoe.mirai.internal.network.protocol.data.proto.CSDataHighwayHead
import net.mamoe.mirai.internal.network.subAppId

View File

@ -16,11 +16,7 @@ import net.mamoe.mirai.event.events.BotOfflineEvent
import net.mamoe.mirai.internal.QQAndroidBot
import net.mamoe.mirai.internal.message.contextualBugReportException
import net.mamoe.mirai.internal.network.Packet
import net.mamoe.mirai.internal.network.components.BdhSessionSyncer
import net.mamoe.mirai.internal.network.components.EventDispatcher
import net.mamoe.mirai.internal.network.components.ServerAddress
import net.mamoe.mirai.internal.network.components.ServerList
import net.mamoe.mirai.internal.network.context.BdhSession
import net.mamoe.mirai.internal.network.components.*
import net.mamoe.mirai.internal.network.networkType
import net.mamoe.mirai.internal.network.protocol.data.jce.FileStoragePushFSSvcList
import net.mamoe.mirai.internal.network.protocol.data.jce.PushResp