aboutsummaryrefslogtreecommitdiffstats
path: root/demo/Main.qml
diff options
context:
space:
mode:
authorThomas Vanbesien <tvanbesi@proton.me>2026-03-23 16:39:33 +0100
committerThomas Vanbesien <tvanbesi@proton.me>2026-03-23 16:39:33 +0100
commit61debe99a269bf7e87f6ba2f8d2a376e619fcf12 (patch)
tree41cf942329760f8a5f16d98ea202124fcae8a0f3 /demo/Main.qml
parent46e96b3318900b561928be304f4a9e252f2785a4 (diff)
downloadQtXpl2-61debe99a269bf7e87f6ba2f8d2a376e619fcf12.tar.gz
QtXpl2-61debe99a269bf7e87f6ba2f8d2a376e619fcf12.zip
Invert TCP connection model: client listens, server connects
The XPL2 protocol specifies that the JI2 controller initiates connections to the client, not the other way around. Xpl2Client now listens on 3 ports via QTcpServer and accepts inbound connections; MockServer connects out with auto-retry on the 1s KA_PING tick. QML API: startListening/stopListening, listening+connected properties, host property removed. Mock server gains --host CLI arg.
Diffstat (limited to 'demo/Main.qml')
-rw-r--r--demo/Main.qml29
1 files changed, 16 insertions, 13 deletions
diff --git a/demo/Main.qml b/demo/Main.qml
index 9b9223f..6aca201 100644
--- a/demo/Main.qml
+++ b/demo/Main.qml
@@ -31,8 +31,9 @@ ApplicationWindow {
Connections {
function onConnectedChanged() {
- debugConsole.appendLog(Xpl2Client.connected ? "Connected" :
- "Disconnected");
+ debugConsole.appendLog(Xpl2Client.connected
+ ? "Controller connected" :
+ "Controller disconnected");
}
function onErrorOccurred(error: string) {
@@ -43,6 +44,12 @@ ApplicationWindow {
statusPage.lastJcStatus = status;
}
+ function onListeningChanged() {
+ debugConsole.appendLog(Xpl2Client.listening
+ ? "Listening on ports 9110/9111/9112" :
+ "Stopped listening");
+ }
+
function onPhStatusReceived(status) {
statusPage.lastPhStatus = status;
}
@@ -95,26 +102,22 @@ ApplicationWindow {
anchors.fill: parent
Label {
- text: "Host:"
+ text: Xpl2Client.connected ? "Controller connected" :
+ "Waiting for controller…"
}
- TextField {
- id: hostField
-
+ Item {
Layout.fillWidth: true
- text: Xpl2Client.host
-
- onEditingFinished: Xpl2Client.host = text
}
Button {
- text: Xpl2Client.connected ? "Disconnect" : "Connect"
+ text: Xpl2Client.listening ? "Stop" : "Listen"
onClicked: {
- if (Xpl2Client.connected)
- Xpl2Client.disconnectFromServer();
+ if (Xpl2Client.listening)
+ Xpl2Client.stopListening();
else
- Xpl2Client.connectToServer();
+ Xpl2Client.startListening();
}
}
}