init method

  1. @override
Future<void> init()
override

Implementation

@override
Future<void> init() async {
  if (_initialized) {
    return;
  }

  // Setup the json RPC server
  jsonRPC = await _createJsonRPCProvider();
  jsonRPC.registerMethod(
    _buildMethod(JSON_RPC_PUBLISH),
    _handlePublish,
  );
  jsonRPC.registerMethod(
    _buildMethod(JSON_RPC_SUBSCRIPTION),
    _handleSubscription,
  );
  jsonRPC.registerMethod(
    _buildMethod(JSON_RPC_SUBSCRIBE),
    _handleSubscribe,
  );
  jsonRPC.registerMethod(
    _buildMethod(JSON_RPC_UNSUBSCRIBE),
    _handleUnsubscribe,
  );
  jsonRPC.listen();

  // Initialize all of our stores
  if (test) {
    _initialized = true;
    return;
  }
  messageTracker ??= MessageTracker(core);
  topicMap ??= TopicMap(core);
  Future.wait([
    messageTracker!.init(),
    topicMap!.init(),
  ]);

  _initialized = true;
}