Class: AwsIotDevice::MqttShadowClient::TokenCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/aws_iot_device/mqtt_shadow_client/token_creator.rb

Instance Method Summary collapse

Constructor Details

#initialize(shadow_name, client_id) ⇒ TokenCreator

This class manage the clients token. Every actions receive a token for a certian interval, meaning that action is waiting to be proceed. When token time run out or the actions have been treated token should deleted.



13
14
15
16
17
18
19
20
21
# File 'lib/aws_iot_device/mqtt_shadow_client/token_creator.rb', line 13

def initialize(shadow_name, client_id)
  if shadow_name.length > 16
    @shadow_name = shadow_name[0..15]
  else
    @shadow_name = shadow_name
  end
  @client_id = client_id
  @sequence_number = 0
end

Instance Method Details

#create_next_tokenObject



23
24
25
26
# File 'lib/aws_iot_device/mqtt_shadow_client/token_creator.rb', line 23

def create_next_token
  token = ""
  token << "#{@client_id}" << "_" << "#{@shadow_name}" << "_" << "#{@sequence_number}" << "_" << "#{random_token_string(5)}"
end