diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-04-02 22:25:35 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-04-02 22:25:35 +0200 |
commit | f4d1f7386dd13fafefba64005f015e2e91140411 (patch) | |
tree | 3c43b95cc8c2fd15929ad9e4cfa658b6ccbc534c /kvision-modules/kvision-remote | |
parent | f1f0423f63cc9f39fa74fc9b68bb680f1d1abd31 (diff) | |
download | kvision-f4d1f7386dd13fafefba64005f015e2e91140411.tar.gz kvision-f4d1f7386dd13fafefba64005f015e2e91140411.tar.bz2 kvision-f4d1f7386dd13fafefba64005f015e2e91140411.zip |
Style fixes and style warnings suppress.
Diffstat (limited to 'kvision-modules/kvision-remote')
-rw-r--r-- | kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt | 3 | ||||
-rw-r--r-- | kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Socket.kt | 32 |
2 files changed, 27 insertions, 8 deletions
diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt index 3e538bd1..9c6f8274 100644 --- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt +++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/KVRemoteAgent.kt @@ -377,6 +377,7 @@ open class KVRemoteAgent<T : Any>(val serviceManager: KVServiceManager<T>) : Rem /** * Executes defined web socket connection */ + @Suppress("ComplexMethod", "TooGenericExceptionCaught") suspend inline fun <reified PAR1 : Any, reified PAR2 : Any> webSocket( noinline function: suspend T.(ReceiveChannel<PAR1>, SendChannel<PAR2>) -> Unit, noinline handler: suspend (SendChannel<PAR1>, ReceiveChannel<PAR2>) -> Unit @@ -446,6 +447,7 @@ open class KVRemoteAgent<T : Any>(val serviceManager: KVServiceManager<T>) : Rem /** * Executes defined web socket connection returning list objects */ + @Suppress("ComplexMethod", "TooGenericExceptionCaught") suspend inline fun <reified PAR1 : Any, reified PAR2 : Any> webSocket( noinline function: suspend T.(ReceiveChannel<PAR1>, SendChannel<List<PAR2>>) -> Unit, noinline handler: suspend (SendChannel<PAR1>, ReceiveChannel<List<PAR2>>) -> Unit @@ -539,6 +541,7 @@ open class KVRemoteAgent<T : Any>(val serviceManager: KVServiceManager<T>) : Rem /** * @suppress internal function */ + @Suppress("TooGenericExceptionCaught") suspend fun exceptionHelper(block: suspend () -> Unit) { try { block() diff --git a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Socket.kt b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Socket.kt index c547ce9b..74edaba0 100644 --- a/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Socket.kt +++ b/kvision-modules/kvision-remote/src/main/kotlin/pl/treksoft/kvision/remote/Socket.kt @@ -90,6 +90,7 @@ class Socket { /** * Receive a string from a websocket. */ + @Suppress("ThrowsCount", "MagicNumber") suspend fun receive(): String { val event = eventQueue.receive() return when (event) { @@ -117,6 +118,7 @@ class Socket { /** * Send string to a websocket. */ + @Suppress("MagicNumber") fun send(obj: String) { when { isClosed() -> { @@ -130,6 +132,7 @@ class Socket { /** * Close a websocket. */ + @Suppress("MagicNumber") fun close(code: Short = 1000) { when (state) { OPEN -> ws.close(code, getReason(1000)) @@ -148,21 +151,34 @@ class Socket { private fun logError(event: Event) = console.error("An error %o occurred when connecting to ${ws.url}", event) + @Suppress("ComplexMethod", "MagicNumber") private fun getReason(code: Short): String { return when (code.toInt()) { // See http://tools.ietf.org/html/rfc6455#section-7.4.1 1000 -> "Normal closure" - 1001 -> "An endpoint is \"going away\", such as a server going down or a browser having navigated away from a page." + 1001 -> "An endpoint is \"going away\", such as a server going down or " + + "a browser having navigated away from a page." 1002 -> "An endpoint is terminating the connection due to a protocol error" - 1003 -> "An endpoint is terminating the connection because it has received a type of data it cannot accept (e.g., an endpoint that understands only text data MAY send this if it receives a binary message)." + 1003 -> "An endpoint is terminating the connection because it has received a type of data it cannot " + + "accept (e.g., an endpoint that understands only text data MAY send this if it receives a " + + "binary message)." 1004 -> "Reserved. The specific meaning might be defined in the future." 1005 -> "No status code was actually present." 1006 -> "The connection was closed abnormally, e.g., without sending or receiving a Close control frame" - 1007 -> "An endpoint is terminating the connection because it has received data within a message that was not consistent with the type of the message (e.g., non-UTF-8 [http://tools.ietf.org/html/rfc3629] data within a text message)." - 1008 -> "An endpoint is terminating the connection because it has received a message that \"violates its policy\". This reason is given either if there is no other sutible reason, or if there is a need to hide specific details about the policy." - 1009 -> "An endpoint is terminating the connection because it has received a message that is too big for it to process." - 1010 -> "An endpoint (client ) is terminating the connection because it has expected the server to negotiate one or more extension, but the server didn't return them in the response message of the WebSocket handshake. <br /> Specifically, the extensions that are needed are: " - 1011 -> "A server is terminating the connection because it encountered an unexpected condition that prevented it from fulfilling the request." - 1015 -> "The connection was closed due to a failure to perform a TLS handshake (e.g., the server certificate can't be verified)." + 1007 -> "An endpoint is terminating the connection because it has received data within a message that " + + "was not consistent with the type of the message (e.g., non-UTF-8 " + + "[http://tools.ietf.org/html/rfc3629] data within a text message)." + 1008 -> "An endpoint is terminating the connection because it has received a message that " + + "\"violates its policy\". This reason is given either if there is no other sutible reason, or " + + "if there is a need to hide specific details about the policy." + 1009 -> "An endpoint is terminating the connection because it has received a message that is too big " + + "for it to process." + 1010 -> "An endpoint (client ) is terminating the connection because it has expected the server to " + + "negotiate one or more extension, but the server didn't return them in the response message of " + + "the WebSocket handshake. <br /> Specifically, the extensions that are needed are: " + 1011 -> "A server is terminating the connection because it encountered an unexpected condition that " + + "prevented it from fulfilling the request." + 1015 -> "The connection was closed due to a failure to perform a TLS handshake (e.g., the server " + + "certificate can't be verified)." 4001 -> "Unexpected event" 4002 -> "You are trying to use closed socket" else -> "Unknown reason" |