mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-05 23:50:08 +08:00
[core] Add QRCodeLoginListener.onCompleted
This commit is contained in:
parent
434ef0cc39
commit
e2d7332ac0
@ -205,6 +205,7 @@ public abstract interface class net/mamoe/mirai/auth/QRCodeLoginListener {
|
||||
public fun getQrCodeMargin ()I
|
||||
public fun getQrCodeSize ()I
|
||||
public fun getQrCodeStateUpdateInterval ()J
|
||||
public fun onCompleted ()V
|
||||
public abstract fun onFetchQRCode (Lnet/mamoe/mirai/Bot;[B)V
|
||||
public fun onIntervalLoop ()V
|
||||
public abstract fun onStateChanged (Lnet/mamoe/mirai/Bot;Lnet/mamoe/mirai/auth/QRCodeLoginListener$State;)V
|
||||
|
@ -205,6 +205,7 @@ public abstract interface class net/mamoe/mirai/auth/QRCodeLoginListener {
|
||||
public fun getQrCodeMargin ()I
|
||||
public fun getQrCodeSize ()I
|
||||
public fun getQrCodeStateUpdateInterval ()J
|
||||
public fun onCompleted ()V
|
||||
public abstract fun onFetchQRCode (Lnet/mamoe/mirai/Bot;[B)V
|
||||
public fun onIntervalLoop ()V
|
||||
public abstract fun onStateChanged (Lnet/mamoe/mirai/Bot;Lnet/mamoe/mirai/auth/QRCodeLoginListener$State;)V
|
||||
|
@ -60,6 +60,12 @@ public interface QRCodeLoginListener {
|
||||
public fun onIntervalLoop() {
|
||||
}
|
||||
|
||||
/**
|
||||
* 当二维码登录扫描完毕时执行, 在此执行资源释放
|
||||
*/
|
||||
public fun onCompleted() {
|
||||
}
|
||||
|
||||
public enum class State {
|
||||
/**
|
||||
* 等待扫描中,请在此阶段请扫描二维码.
|
||||
|
@ -112,6 +112,14 @@ internal class QRCodeLoginProcessorImpl(
|
||||
}
|
||||
|
||||
override suspend fun process(handler: NetworkHandler, client: QQAndroidClient): QRCodeLoginData {
|
||||
return try {
|
||||
process0(handler, client)
|
||||
} finally {
|
||||
qrCodeLoginListener.onCompleted()
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun process0(handler: NetworkHandler, client: QQAndroidClient): QRCodeLoginData {
|
||||
main@ while (true) {
|
||||
val qrCodeData = requestQRCode(handler, client)
|
||||
state@ while (true) {
|
||||
|
Loading…
Reference in New Issue
Block a user