/
examples.lua
71 lines (61 loc) · 1.95 KB
/
examples.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
--
-- Given all funcation names needed register to system
--
function register_hook()
return "on_client_connected",
"on_client_disconnected",
"on_client_subscribe",
"on_client_unsubscribe",
"on_session_subscribed",
"on_session_unsubscribed",
"on_message_delivered",
"on_message_acked",
"on_message_publish"
end
----------------------------------------------------------------------
-- Callback Functions
function on_client_connected(clientid, username, returncode)
print("Lua: on_client_connected - " .. clientid)
-- do your job here
return
end
function on_client_disconnected(clientid, username, reason)
print("Lua: on_client_disconnected - " .. clientid)
-- do your job here
return
end
function on_client_subscribe(clientid, username, topic)
print("Lua: on_client_subscribe - " .. clientid)
-- do your job here
return topic
end
function on_client_unsubscribe(clientid, username, topic)
print("Lua: on_client_unsubscribe - " .. clientid)
-- do your job here
return topic
end
function on_session_subscribed(clientid, username, topic)
print("Lua: on_session_subscribed - " .. clientid)
-- do your job here
return
end
function on_session_unsubscribed(clientid, username, topic)
print("Lua: on_session_unsubscribed - " .. clientid)
-- do your job here
return
end
function on_message_delivered(clientid, username, topic, payload, qos, retain)
print("Lua: on_message_delivered - " .. clientid)
-- do your job here
return topic, payload, qos, retain
end
function on_message_acked(clientid, username, topic, payload, qos, retain)
print("Lua: on_message_acked- " .. clientid)
-- do your job here
return
end
function on_message_publish(clientid, username, topic, payload, qos, retain)
print("Lua: on_message_publish - " .. clientid)
-- do your job here
return topic, payload, qos, retain
end