tree: 43bea352d82f6e735964a19b05d38cda039aab47 [path history] [tgz]
  1. README.md
  2. bin/
  3. fidl/
public/dart/fuchsia_services/examples/mind_reader/README.md

Mind Reader

The mind reader example consists of two components, a client and a server. The example demonstrates a few concepts which are important for understanding how components interact with each other.

Building and Running

To build the example first make sure the package is set to build fx set x64 --product ermine --available topaz/packages/examples/dart_sdk

You can now build the example fx full-build

Ensure that you have the package server running fx serve

In a new window start the logger fx syslog

Optionally, you can filter your logs to only include those that are emitted from the relevant process and control verbosity using --verbosity 4 (where 4 is verbose) fx syslog --tag mind_reader_client

Launch the client (note: if you are not running this on the host but rather on the device directly you can omit the fx shell part of the command) fx shell run "fuchsia-pkg://fuchsia.com/mind_reader_dart#meta/mind_reader_client.cmx"

Now try running the command again but provide a secret thought to expose to the child process (note: if you are invoking this command with fx shell you must escape the quotes to ensure that the parser treats the argument as one string) fx shell run "fuchsia-pkg://fuchsia.com/mind_reader_dart#meta/mind_reader_client.cmx" --thought \"my secret thought\"

Concepts

Launching a Component

The example shows how components can use the fuchsia.sys.Launcher to launch a new component and optionally control its lifecycle.

Exposing a Public Service

When the server is launched it exposes the MindReader service as an outgoing service. This process registers the service in the server's out/public directory. The client component has a handle to this directory and thus can connect to the service.

Exposing a Service to a Launched Component

The client exposes the ThoughtLeaker service to the server component which is launched. This service is made available to the server via its in/svc directory. The server can connect to this service to read the clients thoughts.