Method: SelfSDK::MessagingClient#initialize
- Defined in:
- lib/messaging.rb
permalink #initialize(url, client, storage_key, storage_folder, options = {}) ⇒ MessagingClient
RestClient initializer
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/messaging.rb', line 33 def initialize(url, client, storage_key, storage_folder, = {}) @mon = Monitor.new @url = url @messages = {} @acks = {} @type_observer = {} @uuid_observer = {} @jwt = client.jwt @client = client @ack_timeout = 60 # seconds @timeout = 120 # seconds @device_id = .fetch(:device_id, DEFAULT_DEVICE) @auto_reconnect = .fetch(:auto_reconnect, DEFAULT_AUTO_RECONNECT) @storage_dir = .fetch(:storage_dir, DEFAULT_STORAGE_DIR) @offset_file = "#{@storage_dir}/#{@jwt.id}:#{@device_id}.offset" @offset = read_offset FileUtils.mkdir_p @storage_dir unless File.exist? @storage_dir unless .include? :no_crypto @encryption_client = Crypto.new(@client, @device_id, storage_folder, storage_key) end if .include? :ws @ws = [:ws] else start end end |