start static method

Future<WampMetaStateCache> start(
  1. Session session, {
  2. int maxConcurrentQueries = 16,
})

Starts a cache for an established session.

maxConcurrentQueries bounds the number of concurrent get and member list calls used to hydrate large realms.

Implementation

static Future<WampMetaStateCache> start(
  Session session, {
  int maxConcurrentQueries = 16,
}) async {
  if (maxConcurrentQueries < 1) {
    throw ArgumentError.value(
      maxConcurrentQueries,
      'maxConcurrentQueries',
      'must be at least 1',
    );
  }
  if (!session.isConnected()) {
    throw StateError('The WAMP session must be connected');
  }

  final cache = WampMetaStateCache._(session, maxConcurrentQueries);
  cache._watchDisconnect();
  try {
    await cache._initialize();
    return cache;
  } catch (error, stackTrace) {
    await cache._dispose(releaseSubscriptions: true);
    Error.throwWithStackTrace(error, stackTrace);
  }
}