onConnection method

  1. @override
StreamSubscription<Map<HostEventType, dynamic>> onConnection({
  1. required HostConnectionHandler handler,
})
inherited

Implementation

@override
StreamSubscription<Map<HostEventType, dynamic>> onConnection({
  required HostConnectionHandler handler,
}) {
  final subsription = h.eventStream.listen((event) {
    if (event.containsKey(HostEventType.connection)) {
      final maybeSocket = event.values.first;
      if (maybeSocket is UhstSocket) {
        handler(uhstSocket: maybeSocket);
      }
    }
  });
  h.connectionListenerHandlers
      .update(handler, (value) => subsription, ifAbsent: () => subsription);
  return subsription;
}