|
NAMEAnyEvent::MQTT - AnyEvent module for an MQTT clientVERSIONversion 1.142640SYNOPSISuse AnyEvent::MQTT; my $mqtt = AnyEvent::MQTT->new; my $cv = $mqtt->subscribe(topic => '/topic', callback => sub { my ($topic, $message) = @_; print $topic, ' ', $message, "\n" }); my $qos = $cv->recv; # subscribed, negotiated QoS == $qos # publish a simple message $cv = $mqtt->publish(message => 'simple message', topic => '/topic'); $cv->recv; # sent # publish line-by-line from file handle $cv = $mqtt->publish(handle => \*STDIN, topic => '/topic'); $cv->recv; # sent # publish from AnyEvent::Handle $cv = $mqtt->publish(handle => AnyEvent::Handle->new(my %handle_args), topic => '/topic'); $cv->recv; # sent DESCRIPTIONAnyEvent module for MQTT client.IMPORTANT: This is an early release and the API is still subject to change. METHODS"new(%params)"Constructs a new "AnyEvent::MQTT" object. The supported parameters are:
"cleanup()"This method attempts to destroy any resources in the event of a disconnection or fatal error."publish( %parameters )"This method is used to publish to a given topic. It returns an AnyEvent condvar which is notified when the publish is complete (written to the kernel or ack'd depending on the QoS level). The parameter hash must included at least a topic value and one of:
The parameter hash may also keys for:
"next_message_id()"Returns a 16-bit number to use as the next message id in a message requiring an acknowledgement."subscribe( %parameters )"This method subscribes to the given topic. The parameter hash may contain values for the following keys:
This method returns the value of the cv parameter if it was supplied or an AnyEvent condvar created for this purpose. "unsubscribe( %parameters )"This method unsubscribes to the given topic. The parameter hash may contain values for the following keys:
This method returns the value of the cv parameter if it was supplied or an AnyEvent condvar created for this purpose. "connect( [ $msg ] )"This method starts the connection to the server. It will be called lazily when required publish or subscribe so generally is should not be necessary to call it directly."anyevent_read_type()"This method is used to register an AnyEvent::Handle read type method to read MQTT messages.DISCLAIMERThis is not official IBM code. I work for IBM but I'm writing this in my spare time (with permission) for fun.AUTHORMark Hindess <soft-cpan@temporalanomaly.com>COPYRIGHT AND LICENSEThis software is copyright (c) 2014 by Mark Hindess.This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
Visit the GSP FreeBSD Man Page Interface. |