addChannel method

PhoenixChannel addChannel({
  1. required String topic,
  2. Map<String, dynamic>? parameters,
  3. Duration? timeout,
})

topic is the name of the channel you wish to join parameters are any options parameters you wish to send

Implementation

PhoenixChannel addChannel({
  required String topic,
  Map<String, dynamic>? parameters,
  Duration? timeout,
}) {
  PhoenixChannel? channel = channels[topic];

  if (channel == null) {
    channel = PhoenixChannel.fromSocket(
      this,
      topic: topic,
      parameters: parameters,
      timeout: timeout ?? defaultTimeout,
    );

    channels[channel.topic] = channel;
    _logger.finer(() => 'Adding channel ${channel!.topic}');
  } else {
    _logger.finer(() => 'Reusing existing channel ${channel!.topic}');
  }
  return channel;
}