checkConnection method

Future<bool?> checkConnection()

Checks whether the selected XMR connection is online.

This method sends a CheckConnectionRequest to verify if the selected XMR connection is online.

Example:

final isOnline = await xmrConnectionsClient.checkConnection();
print('Connection is online: $isOnline');

Returns:

  • A Future containing true if the connection is online, false otherwise.

Implementation

Future<bool?> checkConnection() async {
  if (!havenoChannel.isConnected) {
    throw DaemonNotConnectedException();
  }
  try {
    final response = await havenoChannel.xmrConnectionsClient!
        .checkConnection(CheckConnectionRequest());
    return response.connection.onlineStatus == UrlConnection_OnlineStatus.ONLINE;
  } on GrpcError catch (e) {
    handleGrpcError(e);
  }
  return null;
}