![]() |
![]()
| ![]() |
![]()
NAMENet::MQTT::Message - Perl module to represent MQTT messages VERSIONversion 1.143260 SYNOPSISuse 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"; DESCRIPTIONThis module encapsulates a single MQTT message. It uses subclasses to represent specific message types. METHODSnew( %parameters )Constructs an Net::MQTT::Message object based on the given parameters. The common parameter keys are:
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. "new_from_bytes( $packed_bytes, [ $splice ] )"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. message_type()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. dup()The duplicate flag field of the MQTT message. qos()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. retain()The retain field of the MQTT message. remaining()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. "string([ $prefix ])"Returns a summary of the message as a string suitable for logging. If provided, each line will be prefixed by the optional prefix. bytes()Returns the bytes of the message suitable for writing to a socket. 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.
|