From 61debe99a269bf7e87f6ba2f8d2a376e619fcf12 Mon Sep 17 00:00:00 2001 From: Thomas Vanbesien Date: Mon, 23 Mar 2026 16:39:33 +0100 Subject: 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. --- demo/Main.qml | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'demo') 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(); } } } -- cgit v1.2.3