Commit 2b7b8fa6 authored by Him188's avatar Him188

Improve MessagePacket<*, *>.nextMessage

parent 06381e8b
...@@ -162,10 +162,10 @@ fun MessagePacket<*, *>.isContextIdenticalWith(another: MessagePacket<*, *>): Bo ...@@ -162,10 +162,10 @@ fun MessagePacket<*, *>.isContextIdenticalWith(another: MessagePacket<*, *>): Bo
suspend inline fun <reified P : MessagePacket<*, *>> P.nextMessage( suspend inline fun <reified P : MessagePacket<*, *>> P.nextMessage(
timeoutMillis: Long = -1, timeoutMillis: Long = -1,
crossinline filter: P.(P) -> Boolean crossinline filter: P.(P) -> Boolean
): P { ): MessageChain {
return subscribingGet<P, P>(timeoutMillis) { return subscribingGet<P, P>(timeoutMillis) {
takeIf { this.isContextIdenticalWith(this@nextMessage) }?.takeIf { filter(it, it) } takeIf { this.isContextIdenticalWith(this@nextMessage) }?.takeIf { filter(it, it) }
} }.message
} }
/** /**
...@@ -179,8 +179,8 @@ suspend inline fun <reified P : MessagePacket<*, *>> P.nextMessage( ...@@ -179,8 +179,8 @@ suspend inline fun <reified P : MessagePacket<*, *>> P.nextMessage(
*/ */
suspend inline fun <reified P : MessagePacket<*, *>> P.nextMessage( suspend inline fun <reified P : MessagePacket<*, *>> P.nextMessage(
timeoutMillis: Long = -1 timeoutMillis: Long = -1
): P { ): MessageChain {
return subscribingGet<P, P>(timeoutMillis) { return subscribingGet<P, P>(timeoutMillis) {
takeIf { this.isContextIdenticalWith(this@nextMessage) } takeIf { this.isContextIdenticalWith(this@nextMessage) }
} }.message
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment