libMQTTxt v0.0.1 ALPHA - MQTT 3.1.1 Client Library for LiveCode
Alpha release of a pure xTalk MQTT client library for LiveCode Community. Seeking testers for protocol compliance and edge case validation.
Implementation Status
-  MQTT 3.1.1 protocol support (QoS 0, 1, 2)
 
-  TLS/SSL encryption (without certificate verification)
 
-  Auto-reconnection with exponential backoff
 
-  Keep-alive with configurable threshold
 
-  Wildcard subscriptions (+ and #)
 
-  Retained messages
 
-  Last Will and Testament
 
-  Persistent sessions
 
-  Binary-safe message handling
 
-  Multiple simultaneous connections
 
Architecture Notes
The library uses custom properties to pass data from the library stack to your callback handlers:
-  Incoming messages are stored in cMQTT_Topic and cMQTT_Message custom properties
 
-  Library sends message to callback target to invoke wrapper handler
 
-  Wrapper reads custom properties and dispatches to your actual handler
 
This approach ensures reliable message delivery in script-only stacks. Your callback target card requires the __mqttInvokeCallback wrapper (included in test suite).
Quick Start
Code: Select all
-- Load library
start using stack "libMQTTxt.livecode"
-- Configure callbacks
mqttSetCallbackTarget the long id of this card
mqttSetMessageCallback "onMqttMessage"
-- Connect to public broker
put mqttConnect("broker.hivemq.com", 1883, "testClient", "", "", \
                60, false, true, "", "", 0, false, false, false, "") into tResult
-- Subscribe and publish
mqttSubscribe "broker.hivemq.com", 1883, "test/topic", 0
mqttPublish "broker.hivemq.com", 1883, "test/topic", "Hello MQTT", 0, false
-- Callback wrapper (required on your card)
on __mqttInvokeCallback
   global gMQTTMessageCallback
   local tTopic, tMessage
   put the cMQTT_Topic of me into tTopic
   put the cMQTT_Message of me into tMessage
   dispatch gMQTTMessageCallback to me with tTopic, tMessage
end __mqttInvokeCallback
-- Your message handler
on onMqttMessage pTopic, pMessage
   put pTopic && pMessage
end onMqttMessage
 
Test Suite
Included test script validates many test cases:
-  Library initialization and self-test
 
-  Configuration functions
 
-  Connection establishment (plain and TLS)
 
-  QoS 0, 1, 2 message delivery
 
-  Wildcard subscriptions
 
-  Retained messages
 
-  Multiple topic handling
 
-  Binary data support
 
-  Large message handling
 
-  Error validation
 
-  Statistics tracking
 
-  Live connection monitoring
 
Test suite provides real-time feedback and verifies protocol compliance against public brokers.
Known Limitations
-  Alpha quality - expect issues
 
-  No MQTT 5.0 support
 
-  TLS certificate verification not implemented (uses "without verification")
 
-  Persistent store implementation is basic
 
Testing Instructions
1. Load both stacks (library + test suite)
2. Configure broker details in test UI fields
3. Click "Run All Tests"
4. Review results in output field
5. Press ESC during monitoring to disconnect
Public test brokers (no registration):
-  test.mosquitto.org:1883
 
-  broker.hivemq.com:1883
 
-  broker.emqx.io:1883
 
Feedback Requested
-  Connection stability across different brokers
 
-  QoS 2 handshake reliability
 
-  Auto-reconnection behavior
 
-  TLS/SSL connection stability (no verification)
 
-  Performance with high message rates
 
-  Binary data edge cases
 
-  Cross-platform issues
 
Files
-  libMQTTxt.livecode - Library (script-only stack)
 
-  test stack - Test suite (card script with UI)
 
License
GPLv3 - See library header for full terms.
Requirements
LiveCode Community 9.6.3+ or OXT-lite