connectWithCredential method

void connectWithCredential(
  1. CredentialConfig credentialConfig
)

Implementation

void connectWithCredential(CredentialConfig credentialConfig) {
  _logger.i('connect()');
  try {
    if (_pushMetaData != null) {
      txSocket.hostAddress =
          '$_storedHostAddress?voice_sdk_id=${_pushMetaData?.voiceSdkId}';
      _logger.i(
        'Connecting to WebSocket with voice_sdk_id :: ${_pushMetaData?.voiceSdkId}',
      );
    } else {
      txSocket.hostAddress = _storedHostAddress;
      _logger.i('connecting to WebSocket $_storedHostAddress');
    }
    txSocket
      ..onOpen = () {
        _closed = false;
        _connected = true;
        _logger.i('Web Socket is now connected');
        _onOpen();
        credentialLogin(credentialConfig);
      }
      ..onMessage = (dynamic data) {
        _onMessage(data);
      }
      ..onClose = (int closeCode, String closeReason) {
        _logger.i('Closed [$closeCode, $closeReason]!');
        _connected = false;
        _onClose(true, closeCode, closeReason);
      }
      ..connect();
  } catch (e) {
    _logger.e(e.toString());
    _connected = false;
    _logger.e('WebSocket $_storedHostAddress error: $e');
  }
}