Module mqtt.ioloop
ioloop module
Class ioloop_mt
ioloop_mt:__init (args) | Initialize ioloop instance |
ioloop_mt:add (client) | Add MQTT client or a loop function to the ioloop instance |
ioloop_mt:remove (client) | Remove MQTT client or a loop function from the ioloop instance |
ioloop_mt:iteration () | Perform one ioloop iteration |
ioloop_mt:can_sleep () | Perform sleep if no one of the network operation in current iteration was not timeouted |
ioloop_mt:run_until_clients () | Run ioloop until at least one client are in ioloop |
ioloop_mt:get ([autocreate=true[, args]]) | Returns default ioloop instance |
Class ioloop_mt
ioloop instances metatable
- ioloop_mt:__init (args)
-
Initialize ioloop instance
Parameters:
- args ioloop creation arguments table
- timeout number network operations timeout in seconds (default 0.005)
- sleep number sleep interval after each iteration (default 0)
- sleep_function function custom sleep function to call after each iteration (optional)
Returns:
-
ioloop_mt
ioloop instance
- args ioloop creation arguments table
- ioloop_mt:add (client)
-
Add MQTT client or a loop function to the ioloop instance
Parameters:
- client client_mt or function MQTT client or a loop function to add to ioloop
Returns:
-
true on success or false and error message on failure
- ioloop_mt:remove (client)
-
Remove MQTT client or a loop function from the ioloop instance
Parameters:
- client client_mt or function MQTT client or a loop function to remove from ioloop
Returns:
-
true on success or false and error message on failure
- ioloop_mt:iteration ()
- Perform one ioloop iteration
- ioloop_mt:can_sleep ()
- Perform sleep if no one of the network operation in current iteration was not timeouted
- ioloop_mt:run_until_clients ()
- Run ioloop until at least one client are in ioloop
- ioloop_mt:get ([autocreate=true[, args]])
-
Returns default ioloop instance
Parameters:
- autocreate boolean Automatically create ioloop instance (default true)
- args table Arguments for creating ioloop instance (optional)
Returns:
-
ioloop_mt
ioloop instance