handleSessionEvent method

  1. @protected
  2. @override
FutureOr<void> handleSessionEvent(
  1. SessionEvent event
)
override

Handle a SessionEvent from one of this host's sessions.

The base handles the events every mode shares (SessionEventType). Overrides deal with their own protocol's events first and forward the rest with super.handleSessionEvent(event).

Implementation

@protected
@override
// `async` lets one switch return both void and Future handlers.
// ignore: unnecessary_async
FutureOr<void> handleSessionEvent(SessionEvent event) async {
  if (event is SyncSessionEvent) {
    switch (event.type) {
      case SyncSessionEventType.handshakeCompleted:
        return _handleSessionEventHandshakeCompleted(
          event as SyncSessionEventGeneric,
        );

      case SyncSessionEventType.changeApplied:
        return _handleSessionEventChangeApplied(
          event as SessionEventChangeApplied,
        );

      case SyncSessionEventType.documentStatusCreated:
        return _handleSessionEventDocumentStatusRequest(
          event as SyncSessionEventGeneric,
        );

      case SyncSessionEventType.clientOutOfSync:
        return _handleSessionEventClientOutOfSync(
          event as SyncSessionEventGeneric,
        );
    }
  }

  return super.handleSessionEvent(event);
}