PhoenixChannel.fromSocket constructor

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

Build a PhoenixChannel from a PhoenixSocket.

Implementation

PhoenixChannel.fromSocket(
  this.socket, {
  required this.topic,
  Map<String, dynamic>? parameters,
  Duration? timeout,
})  : _controller = StreamController.broadcast(),
      _waiters = {},
      parameters = parameters ?? {},
      _timeout = timeout ?? socket.defaultTimeout {
  _joinPush = _prepareJoin();
  _logger = Logger('phoenix_socket.channel.$loggerName');
  _subscriptions
    ..add(_controller.stream.listen(_onMessage))
    ..addAll(_subscribeToSocketStreams(socket));
}