|
|
@ -1,6 +1,7 @@ |
|
|
|
package io.legado.app.web |
|
|
|
package io.legado.app.web |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import android.os.Looper |
|
|
|
import fi.iki.elonen.NanoHTTPD |
|
|
|
import fi.iki.elonen.NanoHTTPD |
|
|
|
import fi.iki.elonen.NanoWSD |
|
|
|
import fi.iki.elonen.NanoWSD |
|
|
|
import io.legado.app.App |
|
|
|
import io.legado.app.App |
|
|
@ -71,6 +72,7 @@ class SourceDebugWebSocket(handshakeRequest: NanoHTTPD.IHTTPSession) : |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
override fun printLog(state: Int, msg: String) { |
|
|
|
override fun printLog(state: Int, msg: String) { |
|
|
|
|
|
|
|
if (Looper.getMainLooper() == Looper.myLooper()) { |
|
|
|
launch(IO) { |
|
|
|
launch(IO) { |
|
|
|
runCatching { |
|
|
|
runCatching { |
|
|
|
send(msg) |
|
|
|
send(msg) |
|
|
@ -82,6 +84,17 @@ class SourceDebugWebSocket(handshakeRequest: NanoHTTPD.IHTTPSession) : |
|
|
|
it.printStackTrace() |
|
|
|
it.printStackTrace() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
runCatching { |
|
|
|
|
|
|
|
send(msg) |
|
|
|
|
|
|
|
if (state == -1 || state == 1000) { |
|
|
|
|
|
|
|
Debug.cancelDebug(true) |
|
|
|
|
|
|
|
close(NanoWSD.WebSocketFrame.CloseCode.NormalClosure, "调试结束", false) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}.onFailure { |
|
|
|
|
|
|
|
it.printStackTrace() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|