forked from luca/mineqtt
1
0
Fork 0

feat: add installation and usage instructions

This commit is contained in:
Luca 2024-09-05 18:12:00 +02:00
parent c0b86c7659
commit 8e34d4d144
1 changed files with 35 additions and 0 deletions

35
README.md Normal file
View File

@ -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
```