|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2020 the original author or authors. |
|
|
|
* Copyright 2002-2023 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -154,13 +154,13 @@ class RSocketClientToServerCoroutinesIntegrationTests { |
|
|
|
|
|
|
|
|
|
|
|
@MessageMapping("receive-async") |
|
|
|
@MessageMapping("receive-async") |
|
|
|
suspend fun receiveAsync(payload: String) { |
|
|
|
suspend fun receiveAsync(payload: String) { |
|
|
|
delay(10) |
|
|
|
delay(1) |
|
|
|
fireForgetPayloads.tryEmitNext(payload) |
|
|
|
fireForgetPayloads.tryEmitNext(payload) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@MessageMapping("echo-async") |
|
|
|
@MessageMapping("echo-async") |
|
|
|
suspend fun echoAsync(payload: String): String { |
|
|
|
suspend fun echoAsync(payload: String): String { |
|
|
|
delay(10) |
|
|
|
delay(1) |
|
|
|
return "$payload async" |
|
|
|
return "$payload async" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -169,7 +169,7 @@ class RSocketClientToServerCoroutinesIntegrationTests { |
|
|
|
var i = 0 |
|
|
|
var i = 0 |
|
|
|
return flow { |
|
|
|
return flow { |
|
|
|
while(true) { |
|
|
|
while(true) { |
|
|
|
delay(10) |
|
|
|
delay(1) |
|
|
|
emit("$payload ${i++}") |
|
|
|
emit("$payload ${i++}") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -177,11 +177,11 @@ class RSocketClientToServerCoroutinesIntegrationTests { |
|
|
|
|
|
|
|
|
|
|
|
@MessageMapping("echo-stream-async") |
|
|
|
@MessageMapping("echo-stream-async") |
|
|
|
suspend fun echoStreamAsync(payload: String): Flow<String> { |
|
|
|
suspend fun echoStreamAsync(payload: String): Flow<String> { |
|
|
|
delay(10) |
|
|
|
delay(1) |
|
|
|
var i = 0 |
|
|
|
var i = 0 |
|
|
|
return flow { |
|
|
|
return flow { |
|
|
|
while(true) { |
|
|
|
while(true) { |
|
|
|
delay(10) |
|
|
|
delay(1) |
|
|
|
emit("$payload ${i++}") |
|
|
|
emit("$payload ${i++}") |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@ -189,31 +189,31 @@ class RSocketClientToServerCoroutinesIntegrationTests { |
|
|
|
|
|
|
|
|
|
|
|
@MessageMapping("echo-channel") |
|
|
|
@MessageMapping("echo-channel") |
|
|
|
fun echoChannel(payloads: Flow<String>) = payloads.map { |
|
|
|
fun echoChannel(payloads: Flow<String>) = payloads.map { |
|
|
|
delay(10) |
|
|
|
delay(1) |
|
|
|
"$it async" |
|
|
|
"$it async" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Suppress("UNUSED_PARAMETER") |
|
|
|
@Suppress("UNUSED_PARAMETER") |
|
|
|
@MessageMapping("thrown-exception") |
|
|
|
@MessageMapping("thrown-exception") |
|
|
|
suspend fun handleAndThrow(payload: String): String { |
|
|
|
suspend fun handleAndThrow(payload: String): String { |
|
|
|
delay(10) |
|
|
|
delay(1) |
|
|
|
throw IllegalArgumentException("Invalid input error") |
|
|
|
throw IllegalArgumentException("Invalid input error") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@MessageMapping("unit-return-value") |
|
|
|
@MessageMapping("unit-return-value") |
|
|
|
suspend fun unitReturnValue(payload: String) = |
|
|
|
suspend fun unitReturnValue(payload: String) = |
|
|
|
if (payload != "bad") delay(10) else throw IllegalStateException("bad") |
|
|
|
if (payload != "bad") delay(1) else throw IllegalStateException("bad") |
|
|
|
|
|
|
|
|
|
|
|
@MessageExceptionHandler |
|
|
|
@MessageExceptionHandler |
|
|
|
suspend fun handleException(ex: IllegalArgumentException): String { |
|
|
|
suspend fun handleException(ex: IllegalArgumentException): String { |
|
|
|
delay(10) |
|
|
|
delay(1) |
|
|
|
return "${ex.message} handled" |
|
|
|
return "${ex.message} handled" |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Suppress("UNUSED_PARAMETER") |
|
|
|
@Suppress("UNUSED_PARAMETER") |
|
|
|
@MessageExceptionHandler |
|
|
|
@MessageExceptionHandler |
|
|
|
suspend fun handleExceptionWithVoidReturnValue(ex: IllegalStateException) { |
|
|
|
suspend fun handleExceptionWithVoidReturnValue(ex: IllegalStateException) { |
|
|
|
delay(10) |
|
|
|
delay(1) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|