Class: RubyHome::HTTP::HAPRequest

Inherits:
WEBrick::HTTPRequest
  • Object
show all
Defined in:
lib/ruby_home/http/hap_request.rb

Instance Method Summary collapse

Constructor Details

#initialize(*args, request_id:) ⇒ HAPRequest



7
8
9
10
11
12
# File 'lib/ruby_home/http/hap_request.rb', line 7

def initialize(*args, request_id: )
  @_request_id = request_id
  cache[:controller_to_accessory_count] ||= 0

  super(*args)
end

Instance Method Details

#parse(socket = nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ruby_home/http/hap_request.rb', line 14

def parse(socket=nil)
  if decryption_time?
    request_line = socket.read_nonblock(@buffer_size)

    decrypted_request = decrypter.decrypt(request_line).join
    cache[:controller_to_accessory_count] = decrypter.count

    super(StringIO.new(decrypted_request))
  else
    super(socket)
  end
end

#received_encrypted_request?Boolean



27
28
29
# File 'lib/ruby_home/http/hap_request.rb', line 27

def received_encrypted_request?
  cache[:controller_to_accessory_count] >= 1
end