GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Net::MQTT::Message(3) User Contributed Perl Documentation Net::MQTT::Message(3)
 

Net::MQTT::Message - Perl module to represent MQTT messages

version 1.143260

  use Net::MQTT::Constants;
  use Net::MQTT::Message;
  use IO::Socket::INET;
  my $socket = IO::Socket::INET->new(PeerAddr => '127.0.0.1:1883');
  my $mqtt = Net::MQTT::Message->new(message_type => MQTT_CONNECT);
  print $socket $mqtt->bytes;
  my $tcp_payload = pack 'H*', '300d000774657374696e6774657374';
  $mqtt = Net::MQTT::Message->new_from_bytes($tcp_payload);
  print 'Received: ', $mqtt->string, "\n";

This module encapsulates a single MQTT message. It uses subclasses to represent specific message types.

Constructs an Net::MQTT::Message object based on the given parameters. The common parameter keys are:
"message_type"
The message type field of the MQTT message. This should be an integer between 0 and 15 inclusive. The module Net::MQTT::Constants provides constants that can be used for this value. This parameter is required.
"dup"
The duplicate flag field of the MQTT message. This should be either 1 or 0. The default is 0.
"qos"
The QoS field of the MQTT message. This should be an integer between 0 and 3 inclusive. The default is as specified in the spec or 0 ("at most once") otherwise. The module Net::MQTT::Constants provides constants that can be used for this value.
"retain"
The retain flag field of the MQTT message. This should be either 1 or 0. The default is 0.
The remaining keys are dependent on the specific message type. The documentation for the subclasses for each message type list methods with the same name as the required keys.

Attempts to constructs an Net::MQTT::Message object based on the given packed byte string. If there are insufficient bytes, then undef is returned. If the splice parameter is provided and true, then the processed bytes are removed from the scalar referenced by the $packed_bytes parameter.

Returns the message type field of the MQTT message. The module Net::MQTT::Constants provides a function, "message_type_string", that can be used to convert this value to a human readable string.

The duplicate flag field of the MQTT message.

The QoS field of the MQTT message. The module Net::MQTT::Constants provides a function, "qos_string", that can be used to convert this value to a human readable string.

The retain field of the MQTT message.

This contains a packed string of bytes with any of the payload of the MQTT message that was not parsed by these modules. This should not be required for packets that strictly follow the standard.

Returns a summary of the message as a string suitable for logging. If provided, each line will be prefixed by the optional prefix.

Returns the bytes of the message suitable for writing to a socket.

Mark Hindess <soft-cpan@temporalanomaly.com>

This 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.
2014-11-22 perl v5.28.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.