*[<Null safety>](https://dart.dev/null-safety)*
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.
final OpenFlags _openFlags =
OpenFlags.rightReadable | OpenFlags.rightWritable;
// 0755
const int _openMode = 0x1ED;
_dirProxy.open(
_openFlags, _openMode, serviceName, InterfaceRequest<Node>(channel));
}