setStreamHandlerMatch method

  1. @override
void setStreamHandlerMatch(
  1. ProtocolID pid,
  2. bool match(
    1. ProtocolID
    ),
  3. StreamHandler handler
)
override

SetStreamHandlerMatch sets the protocol handler on the Host's Mux using a matching function for protocol selection.

Implementation

@override
void setStreamHandlerMatch(ProtocolID pid, bool Function(ProtocolID) match, StreamHandler handler) {
  _mux.addHandlerWithFunc(pid, match, _handlerFunc(handler));

  // Emit protocol updated event
  if (_evtLocalProtocolsUpdated != null) {
    _evtLocalProtocolsUpdated!.emit(EvtLocalProtocolsUpdated(added: [pid], removed: []));
  }
}