Add a button for closing the connection in secure client example

Change-Id: Icc21315a5a20eeee02b578dc56459d4697a6361d
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
This commit is contained in:
Sona Kurazyan 2019-04-11 15:18:41 +02:00
parent 637b228a38
commit 7706ea9792
3 changed files with 23 additions and 3 deletions

View File

@ -64,8 +64,9 @@ Window {
CoapSecureClient {
id: client
onFinished: {
outputView.text = result
statusLabel.text = ""
outputView.text = result;
statusLabel.text = "";
disconnectButton.enabled = true;
}
}
@ -182,7 +183,6 @@ Window {
id: requestButton
text: qsTr("Send Request")
enabled: securityModeGroup.checkState !== Qt.Unchecked
Layout.columnSpan: 2
onClicked: {
outputView.text = "";
@ -201,6 +201,19 @@ Window {
}
}
Button {
id: disconnectButton
text: qsTr("Disconnect")
enabled: false
onClicked: {
client.disconnect();
statusLabel.text = qsTr("Disconnected.");
outputView.text = "";
disconnectButton.enabled = false;
}
}
TextArea {
id: outputView
placeholderText: qsTr("<Client Output>")

View File

@ -159,3 +159,9 @@ void QmlCoapSecureClient::setSecurityConfiguration(const QString &localCertifica
}
m_configuration = configuration;
}
void QmlCoapSecureClient::disconnect()
{
if (m_coapClient)
m_coapClient->disconnect();
}

View File

@ -68,6 +68,7 @@ public:
Q_INVOKABLE void setSecurityConfiguration(const QString &localCertificatePath,
const QString &caCertificatePath,
const QString &privateKeyPath);
Q_INVOKABLE void disconnect();
Q_SIGNALS:
void finished(const QString &result);