upgradeToSslSocket method

Future<void> upgradeToSslSocket()
inherited

Upgrades the current connection to a secure socket

Implementation

Future<void> upgradeToSslSocket() async {
  _socketStreamSubscription.pause();
  final secureSocket = await SecureSocket.secure(
    _socket,
    context: securityContext,
    onBadCertificate: onBadCertificate,
  );
  logApp('now using secure connection.');
  await _socketStreamSubscription.cancel();
  isSocketClosingExpected = true;
  _socket.destroy();
  isSocketClosingExpected = false;
  connect(secureSocket);
}