connectToServiceWithChannel<T> method

*[<Null safety>](*

void connectToServiceWithChannel <T>(AsyncProxy<T>? serviceProxy, Channel? channel)

Connects to the incoming service specified by serviceProxy 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.


void connectToServiceWithChannel<T>(
    AsyncProxy<T>? serviceProxy, Channel? channel) {
  if (serviceProxy == null) {
    throw ArgumentError.notNull('serviceProxy');
  if (channel == null) {
    throw ArgumentError.notNull('channel');
  final String? serviceName = serviceProxy.ctrl.$serviceName;
  if (serviceName == null) {
    throw Exception(
        "${serviceProxy.ctrl.$interfaceName}'s controller.\$serviceName must "
        'not be null. Check the FIDL file for a missing [Discoverable]');
  connectToServiceByNameWithChannel(serviceName, channel);