Google is committed to advancing racial equity for Black communities. See how.

connectToServiceByNameWithChannel method

void connectToServiceByNameWithChannel (String serviceName, Channel channel)

Connects to the incoming service specified by serviceName through the channel endpoint supplied by the caller.

If the service provider is not willing or able to provide the requested service, it should close the channel.

If this object is not bound via the request method before this method is called an IncomingStateException will be thrown.

Implementation

void connectToServiceByNameWithChannel(String serviceName, Channel channel) {
  if (serviceName == null) {
    throw Exception(
        'serviceName must not be null. Check the FIDL file for a missing '
        '[Discoverable]');
  }
  if (channel == null) {
    throw ArgumentError.notNull('channel');
  }

  if (_dirProxy.ctrl.isUnbound) {
    throw IncomingStateException(
        'The directory must be bound before trying to connect to a service. '
        'See [Incoming.request] for more information');
  }

  // connection flags for service: can read & write from target object.
  const int _openFlags = openRightReadable | openRightWritable;
  // 0755
  const int _openMode = 0x1ED;

  _dirProxy.open(
      _openFlags, _openMode, serviceName, InterfaceRequest<Node>(channel));
}