From a3a3a8ab4b5ecffcd95245f0afb6c26464b5c0d2 Mon Sep 17 00:00:00 2001 From: Aditya Kulkarni Date: Wed, 6 Feb 2019 12:04:53 -0800 Subject: [PATCH] bugfix --- .../kotlin/com/zecqtwallet/wormhole/Service.kt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/com/zecqtwallet/wormhole/Service.kt b/src/main/kotlin/com/zecqtwallet/wormhole/Service.kt index d2381ee..0ffc668 100644 --- a/src/main/kotlin/com/zecqtwallet/wormhole/Service.kt +++ b/src/main/kotlin/com/zecqtwallet/wormhole/Service.kt @@ -34,6 +34,8 @@ fun main(args : Array) { sendError(session, "Message too big") } + println("Recieved $message") + // Parse the message as json try { val j = Parser.default().parse(StringBuilder(message)) as JsonObject @@ -53,9 +55,13 @@ fun main(args : Array) { s[0].send(message) return@onMessage + } else { + println("There was no 'to' in the message") + sendError(session,"Missing 'to' field") + return@onMessage } - } catch (e: Throwable) { + println("Exception: ${e.localizedMessage}") session.close(1000, "Invalid json") } } @@ -70,11 +76,8 @@ fun main(args : Array) { } fun doRegister(session: WsSession, id: String) { - if (usermap.contains(session)) { - sendError(session, "Already registered a session, so disconnecting for bad behaviour") - - usermap.remove(session) - session.close() + if (usermap.containsKey(session)) { + println("Already registered a session") } println("Registered $id")