| 1 | package Net::MQTT::Simple::Auth; | ||
| 2 | |||
| 3 | use parent 'Net::MQTT::Simple'; | ||
| 4 | |||
| 5 | our $VERSION = '0.001'; | ||
| 6 | |||
| 7 | sub new { | ||
| 8 | my ($class, $server, $user, $password, $sockopts) = @_; | ||
| 9 | # @_ == 2 or @_ == 3 or _croak "Wrong number of arguments for $class->new"; | ||
| 10 | |||
| 11 | my $self = $class->SUPER::new ($server, $sockopts); | ||
| 12 | |||
| 13 | $self->{mqtt_user} = $user; | ||
| 14 | $self->{mqtt_password} = $password; | ||
| 15 | |||
| 16 | return $self; | ||
| 17 | } | ||
| 18 | |||
| 19 | sub _send_connect { | ||
| 20 | my ($self) = @_; | ||
| 21 | |||
| 22 | $self->_send("\x10" . Net::MQTT::Simple::_prepend_variable_length( pack ( | ||
| 23 | "x C/a* C C n n/a* n/a* n/a*", | ||
| 24 | $Net::MQTT::Simple::PROTOCOL_NAME, | ||
| 25 | 0x03, | ||
| 26 | 0xC2, | ||
| 27 | $Net::MQTT::Simple::KEEPALIVE_INTERVAL, | ||
| 28 | $self->_client_identifier, | ||
| 29 | $self->{mqtt_user}, | ||
| 30 | $self->{mqtt_password} | ||
| 31 | ))); | ||
| 32 | } | ||
| 33 | |||
| 34 | |||
| 35 | 1; | ||
| 36 | |||
| 37 | __END__ |