getSessionHookCallback method

SessionHookEntry? getSessionHookCallback({
  1. required String sessionId,
  2. required HookEvent event,
  3. required String matcher,
  4. required HookCommand hook,
})

Get callback info for a specific session hook.

Implementation

SessionHookEntry? getSessionHookCallback({
  required String sessionId,
  required HookEvent event,
  required String matcher,
  required HookCommand hook,
}) {
  final store = _stores[sessionId];
  if (store == null) return null;

  final eventMatchers = store.hooks[event];
  if (eventMatchers == null) return null;

  for (final matcherEntry in eventMatchers) {
    if (matcherEntry.matcher == matcher || matcher.isEmpty) {
      for (final hookEntry in matcherEntry.hooks) {
        if (isHookEqual(hookEntry.hook, hook)) {
          return hookEntry;
        }
      }
    }
  }
  return null;
}