class ClientBase

Defined at line 258 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/client_base.h

Client binding specifics

Public Methods

std::shared_ptr<ClientBase> Create (AnyTransport && transport, async_dispatcher_t * dispatcher, AnyIncomingEventDispatcher && event_dispatcher, AsyncEventHandler * error_handler, fidl::AnyTeardownObserver && teardown_observer, ThreadingPolicy threading_policy, std::weak_ptr<ClientControlBlock> client_object_lifetime)

Creates a |ClientBase| by binding to a transport. Notifies

|teardown_observer| on binding teardown.

Defined at line 15 of file ../../sdk/lib/fidl/cpp/wire/client_base.cc

AsyncTeardownResult AsyncTeardown ()

Asynchronously unbind the client from the dispatcher. |teardown_observer|

will be notified on a dispatcher thread. If safe, the managed client

endpoint will be extracted and returned.

Defined at line 43 of file ../../sdk/lib/fidl/cpp/wire/client_base.cc

void PrepareAsyncTxn (ResponseContext * context)

Stores the given asynchronous transaction response context, setting the txid field.

Defined at line 71 of file ../../sdk/lib/fidl/cpp/wire/client_base.cc

void ForgetAsyncTxn (ResponseContext * context)

Forget the transaction associated with the given context. Used when zx_channel_write() fails.

Defined at line 84 of file ../../sdk/lib/fidl/cpp/wire/client_base.cc

void ReleaseResponseContexts (fidl::UnbindInfo info)

Releases all outstanding |ResponseContext|s. Invoked when binding has torn

down.

|info| is the cause of the binding teardown. If |info| represents an error

that is not specific to any single call (e.g. peer closed), all response

contexts would be notified of that error.

Defined at line 92 of file ../../sdk/lib/fidl/cpp/wire/client_base.cc

void SendTwoWay (fidl::OutgoingMessage & message, ResponseContext * context, fidl::WriteOptions write_options)

Sends a two way message.

In the process, registers |context| for the corresponding reply and mints

a new transaction ID. |message| will be updated with that transaction ID.

Errors are notified via |context|.

Defined at line 112 of file ../../sdk/lib/fidl/cpp/wire/client_base.cc

fidl::OneWayStatus SendOneWay (::fidl::OutgoingMessage & message, fidl::WriteOptions write_options)

Sends a one way message.

|message| will have its transaction ID set to zero.

Errors are returned to the caller.

Defined at line 134 of file ../../sdk/lib/fidl/cpp/wire/client_base.cc

std::optional<UnbindInfo> Dispatch (fidl::IncomingHeaderAndMessage & msg, internal::MessageStorageViewBase * storage_view)

Dispatches a generic incoming message.

## Handling events

If the incoming message is an event, the implementation will dispatch it

using |event_dispatcher_| which is created when binding the client.

## Message ownership

If a matching response handler or event handler is found, |msg| is then

consumed, regardless of decoding error. Otherwise, |msg| is not consumed.

## Return value

If errors occur during dispatching, the function will return an

|UnbindInfo| describing the error. Otherwise, it will return

|std::nullopt|.

Defined at line 187 of file ../../sdk/lib/fidl/cpp/wire/client_base.cc

void ClientBase ()

Creates an unbound ClientBase. Only use it with |std::make_shared|.

Defined at line 269 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/client_base.h

void ~ClientBase ()

Defined at line 270 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/client_base.h

void ClientBase (const ClientBase & other)

Neither copyable nor movable.

Defined at line 273 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/client_base.h

ClientBase & operator= (const ClientBase & other)

Defined at line 274 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/client_base.h

void ClientBase (ClientBase && other)

Defined at line 275 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/client_base.h

ClientBase & operator= (ClientBase && other)

Defined at line 276 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/client_base.h

template <typename Callable>
auto MakeSyncCallWith (Callable && sync_call)

Makes a two-way synchronous call with the transport that is managed by this

client.

It invokes |sync_call| with a strong reference to the transport to prevent

its destruction during a |transport.Call|. The |sync_call| callable must

have a return type that could be instantiated with a |fidl::Status| to

propagate failures.

If the client has been unbound, returns a result type instantiated with

a |fidl::Status::Unbound| error.

If the client has a valid binding, returns the return value of |sync_call|.

Defined at line 298 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/client_base.h

size_t GetTransactionCount ()

For debugging.

Defined at line 342 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/client_base.h

const std::weak_ptr<ClientControlBlock> & client_object_lifetime ()

Returns a weak pointer representing the lifetime of client objects exposed

to the user, e.g. |fidl::WireClient|.

When the weak pointer is expired, it indicates that the corresponding

client objects have destructed.

Defined at line 372 of file ../../sdk/lib/fidl/cpp/wire/include/lib/fidl/cpp/wire/client_base.h

Friends

class ClientBaseChecker