Rename Login to LoginHandler

This commit is contained in:
Him188 2019-10-03 19:34:49 +08:00
parent 71a1a40957
commit a157a106e8
2 changed files with 8 additions and 9 deletions

View File

@ -1,8 +1,7 @@
package net.mamoe.mirai.network package net.mamoe.mirai.network
import kotlinx.coroutines.CompletableDeferred
import net.mamoe.mirai.network.protocol.tim.TIMBotNetworkHandler.BotSocket import net.mamoe.mirai.network.protocol.tim.TIMBotNetworkHandler.BotSocket
import net.mamoe.mirai.network.protocol.tim.TIMBotNetworkHandler.Login import net.mamoe.mirai.network.protocol.tim.TIMBotNetworkHandler.LoginHandler
import net.mamoe.mirai.network.protocol.tim.handler.ActionPacketHandler import net.mamoe.mirai.network.protocol.tim.handler.ActionPacketHandler
import net.mamoe.mirai.network.protocol.tim.handler.DataPacketSocket import net.mamoe.mirai.network.protocol.tim.handler.DataPacketSocket
import net.mamoe.mirai.network.protocol.tim.handler.MessagePacketHandler import net.mamoe.mirai.network.protocol.tim.handler.MessagePacketHandler
@ -23,7 +22,7 @@ import net.mamoe.mirai.network.protocol.tim.packet.login.LoginState
* *
* 其中, [PacketHandler] 4 个子模块构成: * 其中, [PacketHandler] 4 个子模块构成:
* - [DebugPacketHandler] 输出 [Packet.toString] * - [DebugPacketHandler] 输出 [Packet.toString]
* - [Login] 处理 touch/login/verification code 相关 * - [LoginHandler] 处理 touch/login/verification code 相关
* - [MessagePacketHandler] 处理消息相关(群消息/好友消息)([ServerEventPacket]) * - [MessagePacketHandler] 处理消息相关(群消息/好友消息)([ServerEventPacket])
* - [ActionPacketHandler] 处理动作相关(踢人/加入群/好友列表等) * - [ActionPacketHandler] 处理动作相关(踢人/加入群/好友列表等)
* *

View File

@ -31,7 +31,7 @@ import javax.imageio.ImageIO
internal class TIMBotNetworkHandler(private val bot: Bot) : BotNetworkHandler { internal class TIMBotNetworkHandler(private val bot: Bot) : BotNetworkHandler {
override val socket: BotSocket = BotSocket() override val socket: BotSocket = BotSocket()
lateinit var login: Login lateinit var loginHandler: LoginHandler
override lateinit var message: MessagePacketHandler override lateinit var message: MessagePacketHandler
override lateinit var action: ActionPacketHandler override lateinit var action: ActionPacketHandler
@ -123,7 +123,7 @@ internal class TIMBotNetworkHandler(private val bot: Bot) : BotNetworkHandler {
withContext(NetworkScope.coroutineContext) { withContext(NetworkScope.coroutineContext) {
launch { launch {
login.onPacketReceived(packet) loginHandler.onPacketReceived(packet)
} }
@ -177,9 +177,9 @@ internal class TIMBotNetworkHandler(private val bot: Bot) : BotNetworkHandler {
fun touch(serverAddress: String, timeoutMillis: Long): CompletableDeferred<LoginState> { fun touch(serverAddress: String, timeoutMillis: Long): CompletableDeferred<LoginState> {
bot.info("Connecting server: $serverAddress") bot.info("Connecting server: $serverAddress")
if (this@TIMBotNetworkHandler::login.isInitialized) { if (this@TIMBotNetworkHandler::login.isInitialized) {
login.close() loginHandler.close()
} }
login = Login() loginHandler = LoginHandler()
this.loginResult = CompletableDeferred() this.loginResult = CompletableDeferred()
serverIP = serverAddress serverIP = serverAddress
@ -243,7 +243,7 @@ internal class TIMBotNetworkHandler(private val bot: Bot) : BotNetworkHandler {
/** /**
* 处理登录过程 * 处理登录过程
*/ */
inner class Login { inner class LoginHandler {
private lateinit var token00BA: ByteArray private lateinit var token00BA: ByteArray
private lateinit var token0825: ByteArray//56 private lateinit var token0825: ByteArray//56
private var loginTime: Int = 0 private var loginTime: Int = 0
@ -370,7 +370,7 @@ internal class TIMBotNetworkHandler(private val bot: Bot) : BotNetworkHandler {
socket.loginResult!!.complete(LoginState.SUCCESS) socket.loginResult!!.complete(LoginState.SUCCESS)
login.changeOnlineStatus(ClientLoginStatus.ONLINE) loginHandler.changeOnlineStatus(ClientLoginStatus.ONLINE)
} }
is ServerLoginSuccessPacket -> { is ServerLoginSuccessPacket -> {