| 1 | 3 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 2 | 3 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 3 | package Net::MQTT::Message::Connect; | ||||||||||||||||||
| 4 | 3 | $Net::MQTT::Message::Connect::VERSION = '1.143250'; | |||||||||||||||||
| 5 | # ABSTRACT: Perl module to represent an MQTT Connect message | ||||||||||||||||||
| 6 | |||||||||||||||||||
| 7 | |||||||||||||||||||
| 8 | 3 | ▶ | use base 'Net::MQTT::Message'; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 9 | 3 | ▶ | use Net::MQTT::Constants qw/:all/; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 10 | |||||||||||||||||||
| 11 | sub message_type { | ||||||||||||||||||
| 12 | 15 | ▶ | 1 | ||||||||||||||||
|
Subroutine
message_type: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 13 | } | ||||||||||||||||||
| 14 | |||||||||||||||||||
| 15 | |||||||||||||||||||
| 16 | 12 | ▶ | sub protocol_name { shift->{protocol_name} || 'MQIsdp' } | ||||||||||||||||
|
Subroutine
protocol_name: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||
| 17 | |||||||||||||||||||
| 18 | |||||||||||||||||||
| 19 | 12 | ▶ | sub protocol_version { shift->{protocol_version} || 3 } | ||||||||||||||||
|
Subroutine
protocol_version: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | |||||||||||||||||||
| 22 | sub user_name_flag { | ||||||||||||||||||
| 23 | 21 | ▶ | my $self = shift; | ||||||||||||||||
|
Subroutine
user_name_flag: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 24 | 21 | ▶ | $self->{user_name_flag} || defined $self->{user_name}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 25 | } | ||||||||||||||||||
| 26 | |||||||||||||||||||
| 27 | |||||||||||||||||||
| 28 | sub password_flag { | ||||||||||||||||||
| 29 | 21 | ▶ | my $self = shift; | ||||||||||||||||
|
Subroutine
password_flag: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 30 | 21 | ▶ | $self->{password_flag} || defined $self->{password}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 31 | } | ||||||||||||||||||
| 32 | |||||||||||||||||||
| 33 | |||||||||||||||||||
| 34 | 8 | ▶ | sub will_retain { shift->{will_retain} || 0 } | ||||||||||||||||
|
Subroutine
will_retain: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||
| 35 | |||||||||||||||||||
| 36 | |||||||||||||||||||
| 37 | 8 | ▶ | sub will_qos { shift->{will_qos} || 0 } | ||||||||||||||||
|
Subroutine
will_qos: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | |||||||||||||||||||
| 40 | sub will_flag { | ||||||||||||||||||
| 41 | 27 | ▶ | my $self = shift; | ||||||||||||||||
|
Subroutine
will_flag: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 42 | $self->{will_flag} || defined $self->{will_topic} | ||||||||||||||||||
| 43 | 27 | ▶ | } | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 44 | |||||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | sub clean_session { | ||||||||||||||||||
| 47 | 6 | ▶ | my $self = shift; | ||||||||||||||||
|
Subroutine
clean_session: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 48 | 6 | ▶ | defined $self->{clean_session} ? $self->{clean_session} : 1 | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 49 | } | ||||||||||||||||||
| 50 | |||||||||||||||||||
| 51 | |||||||||||||||||||
| 52 | 6 | ▶ | sub connect_reserved_flag { shift->{connect_reserved_flag} || 0 } | ||||||||||||||||
|
Subroutine
connect_reserved_flag: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||
| 53 | |||||||||||||||||||
| 54 | |||||||||||||||||||
| 55 | 6 | ▶ | sub keep_alive_timer { shift->{keep_alive_timer} || 60 } | ||||||||||||||||
|
Subroutine
keep_alive_timer: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||
| 56 | |||||||||||||||||||
| 57 | |||||||||||||||||||
| 58 | 14 | ▶ | sub client_id { shift->{client_id} || 'NetMQTTpm'.$$ } | ||||||||||||||||
|
Subroutine
client_id: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||
| 59 | |||||||||||||||||||
| 60 | |||||||||||||||||||
| 61 | 4 | ▶ | sub will_topic { shift->{will_topic} } | ||||||||||||||||
|
Subroutine
will_topic: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 62 | |||||||||||||||||||
| 63 | |||||||||||||||||||
| 64 | 4 | ▶ | sub will_message { shift->{will_message} } | ||||||||||||||||
|
Subroutine
will_message: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 65 | |||||||||||||||||||
| 66 | |||||||||||||||||||
| 67 | 4 | ▶ | sub user_name { shift->{user_name} } | ||||||||||||||||
|
Subroutine
user_name: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 68 | |||||||||||||||||||
| 69 | |||||||||||||||||||
| 70 | 4 | ▶ | sub password { shift->{password} } | ||||||||||||||||
|
Subroutine
password: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||
| 71 | |||||||||||||||||||
| 72 | sub _remaining_string { | ||||||||||||||||||
| 73 | 6 | ▶ | my ($self, $prefix) = @_; | ||||||||||||||||
|
Subroutine
_remaining_string: called CC=4 SCAR=13.9
| |||||||||||||||||||
| 74 | 6 | ▶ | $self->protocol_name.'/'.$self->protocol_version.'/'.$self->client_id. | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 75 | ($self->user_name_flag ? ' user='.$self->user_name : ''). | ||||||||||||||||||
| 76 | ($self->password_flag ? ' pass='.$self->password : ''). | ||||||||||||||||||
| 77 | ($self->will_flag | ||||||||||||||||||
| 78 | ? ' will='.$self->will_topic.',"'.$self->will_message.'",'. | ||||||||||||||||||
| 79 | $self->will_retain.','.qos_string($self->will_qos) : ''). | ||||||||||||||||||
| 80 | ' '.$self->SUPER::_remaining_string($prefix) | ||||||||||||||||||
| 81 | } | ||||||||||||||||||
| 82 | |||||||||||||||||||
| 83 | sub _parse_remaining { | ||||||||||||||||||
| 84 | 3 | ▶ | my $self = shift; | ||||||||||||||||
|
Subroutine
_parse_remaining: called CC=4 SCAR=13.9
| |||||||||||||||||||
| 85 | 3 | my $offset = 0; | |||||||||||||||||
| 86 | 3 | $self->{protocol_name} = decode_string($self->{remaining}, \$offset); | |||||||||||||||||
| 87 | 3 | $self->{protocol_version} = decode_byte($self->{remaining}, \$offset); | |||||||||||||||||
| 88 | 3 | my $b = decode_byte($self->{remaining}, \$offset); | |||||||||||||||||
| 89 | 3 | $self->{user_name_flag} = ($b&0x80) >> 7; | |||||||||||||||||
| 90 | 3 | $self->{password_flag} = ($b&0x40) >> 6; | |||||||||||||||||
| 91 | 3 | $self->{will_retain} = ($b&0x20) >> 5; | |||||||||||||||||
| 92 | 3 | $self->{will_qos} = ($b&0x18) >> 3; | |||||||||||||||||
| 93 | 3 | $self->{will_flag} = ($b&0x4) >> 2; | |||||||||||||||||
| 94 | 3 | $self->{clean_session} = ($b&0x2) >> 1; | |||||||||||||||||
| 95 | 3 | $self->{connect_reserved_flag} = $b&0x1; | |||||||||||||||||
| 96 | 3 | $self->{keep_alive_timer} = decode_short($self->{remaining}, \$offset); | |||||||||||||||||
| 97 | 3 | $self->{client_id} = decode_string($self->{remaining}, \$offset); | |||||||||||||||||
| 98 | 3 | ▶ | if ($self->will_flag) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 99 | 1 | $self->{will_topic} = decode_string($self->{remaining}, \$offset); | |||||||||||||||||
| 100 | 1 | $self->{will_message} = decode_string($self->{remaining}, \$offset); | |||||||||||||||||
| 101 | } | ||||||||||||||||||
| 102 | 3 | ▶ | if ($self->user_name_flag) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 103 | 1 | $self->{user_name} = decode_string($self->{remaining}, \$offset); | |||||||||||||||||
| 104 | } | ||||||||||||||||||
| 105 | 3 | ▶ | if ($self->password_flag) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 106 | 1 | $self->{password} = decode_string($self->{remaining}, \$offset); | |||||||||||||||||
| 107 | } | ||||||||||||||||||
| 108 | 3 | substr $self->{remaining}, 0, $offset, ''; | |||||||||||||||||
| 109 | } | ||||||||||||||||||
| 110 | |||||||||||||||||||
| 111 | sub _remaining_bytes { | ||||||||||||||||||
| 112 | 6 | ▶ | my $self = shift; | ||||||||||||||||
|
Subroutine
_remaining_bytes: called CC=5 SCAR=16.1
| |||||||||||||||||||
| 113 | 6 | my $o = encode_string($self->protocol_name); | |||||||||||||||||
| 114 | 6 | $o .= encode_byte($self->protocol_version); | |||||||||||||||||
| 115 | 6 | $o .= encode_byte( | |||||||||||||||||
| 116 | ($self->user_name_flag << 7) | | ||||||||||||||||||
| 117 | ($self->password_flag << 6) | | ||||||||||||||||||
| 118 | ($self->will_retain << 5) | ($self->will_qos << 3) | | ||||||||||||||||||
| 119 | ($self->will_flag << 2) | | ||||||||||||||||||
| 120 | ($self->clean_session << 1) | | ||||||||||||||||||
| 121 | $self->connect_reserved_flag); | ||||||||||||||||||
| 122 | 6 | $o .= encode_short($self->keep_alive_timer); | |||||||||||||||||
| 123 | 6 | $o .= encode_string($self->client_id); | |||||||||||||||||
| 124 | 6 | ▶ | $o .= encode_string($self->will_topic) if ($self->will_flag); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 125 | 6 | ▶ | $o .= encode_string($self->will_message) if ($self->will_flag); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 126 | 6 | ▶ | $o .= encode_string($self->user_name) if ($self->user_name_flag); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 127 | 6 | ▶ | $o .= encode_string($self->password) if ($self->password_flag); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 128 | 6 | $o; | |||||||||||||||||
| 129 | } | ||||||||||||||||||
| 130 | |||||||||||||||||||
| 131 | 3 | 1; | |||||||||||||||||
| 132 | |||||||||||||||||||
| 133 | __END__ | ||||||||||||||||||