From e867cbd2bd233f1a65eb54ea4ca288f0a3f36e99 Mon Sep 17 00:00:00 2001 From: gedoor Date: Thu, 28 Jan 2021 10:54:51 +0800 Subject: [PATCH] edit SourceDebugWebSocket.kt --- app/src/main/java/io/legado/app/web/SourceDebugWebSocket.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/io/legado/app/web/SourceDebugWebSocket.kt b/app/src/main/java/io/legado/app/web/SourceDebugWebSocket.kt index 747a741f5..2b5a1c11b 100644 --- a/app/src/main/java/io/legado/app/web/SourceDebugWebSocket.kt +++ b/app/src/main/java/io/legado/app/web/SourceDebugWebSocket.kt @@ -42,9 +42,13 @@ class SourceDebugWebSocket(handshakeRequest: NanoHTTPD.IHTTPSession) : } override fun onMessage(message: NanoWSD.WebSocketFrame) { - if (!message.textPayload.isJson()) return launch(IO) { kotlin.runCatching { + if (!message.textPayload.isJson()) { + send("数据必须为Json格式") + close(NanoWSD.WebSocketFrame.CloseCode.NormalClosure, "调试结束", false) + return@launch + } val debugBean = GSON.fromJsonObject>(message.textPayload) if (debugBean != null) { val tag = debugBean["tag"]