From 8e34d4d144f76b79ea51f6218e472e96a1945f54 Mon Sep 17 00:00:00 2001 From: Luca Date: Thu, 5 Sep 2024 18:12:00 +0200 Subject: [PATCH] feat: add installation and usage instructions --- README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..e18ba08 --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +# MineQTT + +## Installation + +```lua +local net = require("internet"); local io = require("io"); f = io.open("/lib/mqtt.lua", "w"); for line in net.request("https://git.luj0ga.de/luca/mineqtt/raw/branch/main/mqtt.lua") do f:write(line) end; f:flush():close() +``` + +## Usage + +```lua +local mqtt = require("mqtt") + +local client, err = mqtt.open("mqtt.example.org", 1883) +if err ~= nil then + error(err) +end + +local err = client:connect() +if err ~= nil then + error(err) +end + +local err = client:handle() +if err ~= nil then + error(err) +end + +print(client.is_connected) + +local err = client:disconnect() +if err ~= nil then + error(err) +end +```