use strict;
use warnings;
package Net::MQTT::Message::Subscribe;
$Net::MQTT::Message::Subscribe::VERSION = '1.163170';
# ABSTRACT: Perl module to represent an MQTT Subscribe message

use base 'Net::MQTT::Message';
use Net::MQTT::Constants qw/:all/;

sub message_type {

sub _default_qos {

sub message_id { shift->{message_id} }

sub topics { shift->{topics} }

sub _topics_string {
  join  ',', map { $_->[0].'/'.qos_string($_->[1]) } @{shift->{topics}}

sub _remaining_string {
  my ($self, $prefix) = @_;
  $self->message_id.' '.$self->_topics_string.' '.

sub _parse_remaining {
  my $self = shift;
  my $offset = 0;
  $self->{message_id} = decode_short($self->{remaining}, \$offset);
  while ($offset < length $self->{remaining}) {
    push @{$self->{topics}}, [ decode_string($self->{remaining}, \$offset),
                               decode_byte($self->{remaining}, \$offset) ];
  substr $self->{remaining}, 0, $offset, '';

sub _remaining_bytes {
  my $self = shift;
  my $o = encode_short($self->message_id);
  foreach my $r (@{$self->topics}) {
    my ($name, $qos) = @$r;
    $o .= encode_string($name);
    $o .= encode_byte($qos);




=encoding UTF-8

=head1 NAME

Net::MQTT::Message::Subscribe - Perl module to represent an MQTT Subscribe message

=head1 VERSION

version 1.163170


  # instantiated by Net::MQTT::Message


This module encapsulates a single MQTT Subscribe message.  It is a
specific subclass used by L<Net::MQTT::Message> and should not
need to be instantiated directly.

=head1 METHODS

=head2 C<message_id()>

Returns the message id field of the MQTT Subscribe message.

=head2 C<topics()>

Returns the list of topics of the MQTT Subscribe message.  Each
element of the list is a 2-ple containing the topic and its associated
requested QoS level.

=head1 AUTHOR

Mark Hindess <>


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.