Net::MQTT::Simple::One_Shot_Loader - Perl package to add one_shot method to Net::MQTT::Simple
require Net::MQTT::Simple::One_Shot_Loader; use Net::MQTT::Simple; #or Net::MQTT::Simple::SSL my $mqtt = Net::MQTT::Simple->new($host); my $obj = $mqtt->one_shot($topic_sub, $topic_pub, $message_pub, $timeout_seconds); #isa Net::MQTT::Simple::One_Shot_Loader::Response my $value = $obj->message;
This package loads the one_shot method into the Net::MQTT::Simple name space to provide a well tested remote procedure call (RPC) via MQTT. Many IoT devices only support MQTT as a protocol so, in order to query state or settings these properties need to be requested by sending a message on one queue and receiving a response on another queue.
one_shot
Due to the way Net::MQTT::Simple::SSL was implemented as a super class of Net::MQTT::Simple and since the author of Net::MQTT::Simple did not want to implement this method in his package (ref GitHub), we implemented this method in a method loader package.
Returns an object representing the first message that matches the subscription topic after publishing the message on the message topic. Returns an object with the error set to a true value on error like timeout.
my $response = $mqtt->one_shot($topic_sub, $topic_pub, $message_pub, $timeout_seconds); if (not $response->error) { my $message = $response->message; }
Net::MQTT::Simple
Michael R. Davis
MIT License
Copyright (c) 2023 Michael R. Davis
To install Net::MQTT::Simple::One_Shot_Loader, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Net::MQTT::Simple::One_Shot_Loader
CPAN shell
perl -MCPAN -e shell install Net::MQTT::Simple::One_Shot_Loader
For more information on module installation, please visit the detailed CPAN module installation guide.