Skip to content

Commit

Permalink
fix once() method
Browse files Browse the repository at this point in the history
  • Loading branch information
shw0471 committed Mar 29, 2022
1 parent 13fb611 commit d086e9d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cocket/src/main/java/com/semicolon/cocket/CocketExecutor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,10 @@ class CocketExecutor(

private fun once(method: Method): Any {
require(method.returnType == Flow::class.java) { "@ReceiveOnce method should return coroutine Flow." }
val event = (method.annotations[0] as On).value
val event = (method.annotations[0] as Once).value
val genericType = (method.genericReturnType as ParameterizedType).actualTypeArguments[0]
return callbackFlow<Any> {
socketClient.on(event) {
socketClient.once(event) {
if (genericType != Unit.javaClass)
trySend(gson.fromJson(it[0].toString(), genericType))
else trySend(Unit)
Expand Down

0 comments on commit d086e9d

Please sign in to comment.