defineHooks function

Hooks defineHooks({
  1. required FutureOr<void> message(
    1. Peer peer,
    2. Message message
    ),
  2. FutureOr<void> open(
    1. Peer peer
    )?,
  3. FutureOr<void> close(
    1. Peer peer, [
    2. int? code,
    3. String? reason
    ])?,
  4. FutureOr<void> error(
    1. Peer peer,
    2. Object? error
    )?,
  5. FutureOr<Headers?> upgrade(
    1. Event event
    )?,
})

Define a Hooks.

Implementation

Hooks defineHooks({
  required FutureOr<void> Function(Peer peer, Message message) message,
  FutureOr<void> Function(Peer peer)? open,
  FutureOr<void> Function(Peer peer, [int? code, String? reason])? close,
  FutureOr<void> Function(Peer peer, Object? error)? error,
  FutureOr<Headers?> Function(Event event)? upgrade,
}) {
  return _DefinedHooks(
    onMessage: message,
    onOpen: open,
    onClose: close,
    onError: error,
    onUpgrade: upgrade,
  );
}