receive
receive(driver:filter:assert:timeout:)
public func receive(driver: TransportDriver, filter: TransportFilter, assert: TransportFilter?, timeout: UInt?) async throws -> TransportPayload
Receive a specific message
This method awaits until a matching message is received (determined by filter
) and resolves with
message data. If an assert
filter is specified, the message is also checked against it and throws if
that assertion fails. Such behaviour comes handy for sudden unsubscribing, receiving messages out of order
and other erroneous situations.
Parameters
Name | Description |
---|---|
driver | TransportDriver implementation |
filter | incoming message filter |
assert | (optional) secondary incoming message filter, asserting out-of-order messages |
timeout | (optional) maximum await delay (in milliseconds), after which the receiver automatically unsubscribes |
Returns
TransportPayload
received message payload (TransportPayload
) (both meta and data)