class AwsIotDevice::MqttShadowClient::TokenCreator
Public Class Methods
new(shadow_name, client_id)
click to toggle source
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.
# File lib/aws_iot_device/mqtt_shadow_client/token_creator.rb, line 13 def initialize(shadow_name, client_id) @shadow_name = shadow_name @client_id = client_id @sequence_number = 0 end
Public Instance Methods
create_next_token()
click to toggle source
# File lib/aws_iot_device/mqtt_shadow_client/token_creator.rb, line 19 def create_next_token token = "" token << "#{@client_id}" << "_" << "#{@shadow_name}" << "_" << "#{@sequence_number}" << "_" << "#{random_token_string(5)}" end
Private Instance Methods
random_token_string(lenght)
click to toggle source
# File lib/aws_iot_device/mqtt_shadow_client/token_creator.rb, line 26 def random_token_string(lenght) charset = Array('A'..'Z') + Array('a'..'z') + Array('0'..'9') Array.new(lenght) { charset.sample }.join end