createConnection method

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

Implementation

@override
Future<void> createConnection() async {
  if (!isConnectionAvailable()) {
    //1. find secondary url for atsign from lookup library
    var secondaryUrl = await AtLookupImpl.findSecondary(
        _currentAtSign, _rootDomain, _rootPort);
    if (secondaryUrl == null) {
      throw SecondaryNotFoundException('Secondary server not found');
    }
    var secondaryInfo = LookUpUtil.getSecondaryInfo(secondaryUrl);
    //2. create a connection to secondary server
    await createOutBoundConnection(
        secondaryInfo[0], secondaryInfo[1], _currentAtSign);
    //3. listen to server response
    messageListener = SyncMessageListener(connection);
    messageListener.syncCallback = syncCallback;
    messageListener.listen();
  }
}