Coder Social home page Coder Social logo

perl-net-mqtt-simple-one_shot_loader's Introduction

NAME

Net::MQTT::Simple::One_Shot_Loader - Perl package to add one_shot method to Net::MQTT::Simple

SYNOPSIS

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;

DESCRIPTION

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.

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.

METHODS

one_shot

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;
}

SEE ALSO

Net::MQTT::Simple

AUTHOR

Michael R. Davis

COPYRIGHT AND LICENSE

MIT License

Copyright (c) 2023 Michael R. Davis

perl-net-mqtt-simple-one_shot_loader's People

Contributors

mrdvt92 avatar

Watchers

 avatar

perl-net-mqtt-simple-one_shot_loader's Issues

Can't locate IO/Socket/SSL.pm in @INC

The test suite fails on some of my smokers --- probably due to a missing PREREQ_PM declaration or so:

#   Failed test 'use Net::MQTT::Simple::SSL;'
#   at t/001_load.t line 7.
#     Tried to use 'Net::MQTT::Simple::SSL'.
#     Error:  Can't locate IO/Socket/SSL.pm in @INC (you may need to install the IO::Socket::SSL module) (@INC contains: /home/cpansand/.cpan/build/2023032519/Net-MQTT-Simple-One_Shot_Loader-0.02-0/blib/lib /home/cpansand/.cpan/build/2023032519/Net-MQTT-Simple-One_Shot_Loader-0.02-0/blib/arch /home/cpansand/.cpan/build/2023032519/Net-MQTT-Simple-1.28-0/blib/arch /home/cpansand/.cpan/build/2023032519/Net-MQTT-Simple-1.28-0/blib/lib /home/cpansand/.cpan/build/2023032519/Net-MQTT-Simple-1.28-0/blib/arch /home/cpansand/.cpan/build/2023032519/Net-MQTT-Simple-1.28-0/blib/lib /opt/perl-5.28.3t/lib/site_perl/5.28.3/x86_64-linux-thread-multi /opt/perl-5.28.3t/lib/site_perl/5.28.3 /opt/perl-5.28.3t/lib/5.28.3/x86_64-linux-thread-multi /opt/perl-5.28.3t/lib/5.28.3 .) at /home/cpansand/.cpan/build/2023032519/Net-MQTT-Simple-1.28-0/blib/lib/Net/MQTT/Simple/SSL.pm line 5.
# BEGIN failed--compilation aborted at /home/cpansand/.cpan/build/2023032519/Net-MQTT-Simple-1.28-0/blib/lib/Net/MQTT/Simple/SSL.pm line 5.
# Compilation failed in require at t/001_load.t line 7.
# BEGIN failed--compilation aborted at t/001_load.t line 7.
# Looks like you failed 1 test of 5.
t/001_load.t ............. 
Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/5 subtests 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.