class MessageReader
Defined at line 25 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/internal/message_reader.h
Public Methods
void MessageReader (const MessageReader & )
Defined at line 30 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/internal/message_reader.h
MessageReader & operator= (const MessageReader & )
Defined at line 31 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/internal/message_reader.h
void MessageReader (MessageHandler * message_handler)
Defined at line 74 of file ../../sdk/lib/fidl/hlcpp/internal/message_reader.cc
bool is_bound ()
Whether the |MessageReader| is currently bound.
See |Bind()| and |Unbind()|.
Defined at line 77 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/internal/message_reader.h
const zx::channel & channel ()
The channel to which this |MessageReader| is bound, if any.
Defined at line 80 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/internal/message_reader.h
void ~MessageReader ()
Defined at line 82 of file ../../sdk/lib/fidl/hlcpp/internal/message_reader.cc
async_dispatcher_t * dispatcher ()
The |async_dispatcher_t| to which this |MessageReader| is bound, if any.
Defined at line 83 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/internal/message_reader.h
zx_status_t Bind (zx::channel channel, async_dispatcher_t * dispatcher)
Binds the given channel to this |MessageReader|.
The |MessageReader| will wait asynchronously for messages on this channel
and dispatch them to the message handler using |dispatcher|. After this
method returns, the |MessageReader| will be waiting for incomming messages.
If the |MessageReader| is already bound, the |MessageReader| will first
be unbound.
If |dispatcher| is null, the current thread must have a default
async_dispatcher_t.
Defined at line 92 of file ../../sdk/lib/fidl/hlcpp/internal/message_reader.cc
void set_message_handler (MessageHandler * message_handler)
The given message handler is called whenever the |MessageReader| reads a
message from the channel.
The |Message| given to the message handler will be valid until the message
handler returns.
The handler should return ZX_OK if the message was handled and an error
otherwise. If the handler returns ZX_OK, the |MessageReader| will continue
to wait for messages.
The handler can destroy the |MessageReader|, in which case the
handler MUST return |ZX_ERR_STOP|. If the handler returns
|ZX_ERR_SHOULD_WAIT|, the |MessageReader| will continue waiting. Other
errors cause the |MessageReader| to unbind from the channel and call the
error handler.
Defined at line 108 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/internal/message_reader.h
bool has_error_handler ()
Whether an error handler has been set.
See |set_error_handler()|.
Defined at line 113 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/internal/message_reader.h
zx::channel Unbind ()
Unbinds the channel from this |MessageReader|.
The |MessageReader| will stop waiting for the messages on this channel.
Returns the channel to which this |MessageReader| was previously bound, if
any.
Defined at line 114 of file ../../sdk/lib/fidl/hlcpp/internal/message_reader.cc
void Reset ()
Unbinds the channel from this |MessageReader| and clears the error handler.
Defined at line 127 of file ../../sdk/lib/fidl/hlcpp/internal/message_reader.cc
void set_error_handler (fit::function<void (zx_status_t)> error_handler)
The given error handler is called whenever the |MessageReader| encounters
an error on the channel.
If the error is being reported because an error occurred on the local side
of the channel, the zx_status_t of that error will be passed as the
parameter to the handler.
If an Epitaph was present on the channel, its error value will be passed as
the parameter. See the FIDL language specification for more detail on
Epitaphs.
For example, the error handler will be called if the remote side of the
channel sends an invalid message. When the error handler is called, the
|Binding| will no longer be bound to the channel.
The handler can destroy the |MessageReader|.
Defined at line 131 of file ../../sdk/lib/fidl/hlcpp/include/lib/fidl/cpp/internal/message_reader.h
zx_status_t TakeChannelAndErrorHandlerFrom (MessageReader * other)
Unbinds the channel from |other| and bindings it to this |MessageReader|.
Also moves the error handler from |other| to this |MessageReader|.
Useful for implementing move semantics for objects that have a
|MessageReader|.
Defined at line 132 of file ../../sdk/lib/fidl/hlcpp/internal/message_reader.cc
zx_status_t Close (zx_status_t epitaph_value)
Sends an epitaph with the given value, unbinds, and then closes the channel
associated with this |MessageReader|.
The |MessageReader| will send an Epitaph with the given error, unbind
the channel, and then close it.
The return value can be any of the return values of zx_channel_write.
Defined at line 243 of file ../../sdk/lib/fidl/hlcpp/internal/message_reader.cc
zx_status_t WaitAndDispatchOneMessageUntil (zx::time deadline)
Synchronously waits on |channel()| until either a message is available or
the peer closes. If the channel is readable, reads a single message from
the channel and dispatches it to the message handler.
Returns |ZX_ERR_BAD_STATE| if this |MessageReader| is not bound, or if it
receives a malformed Epitaph.
Defined at line 140 of file ../../sdk/lib/fidl/hlcpp/internal/message_reader.cc
Friends
class ProxyController