Class: RubyHome::HAP::HAPResponse

Inherits:
WEBrick::HTTPResponse
  • Object
show all
Defined in:
lib/ruby_home/hap/hap_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, sock) ⇒ HAPResponse



4
5
6
7
8
9
# File 'lib/ruby_home/hap/hap_response.rb', line 4

def initialize(config, sock)
  @sock = sock
  cache[:accessory_to_controller_count] ||= 0

  super(config)
end

Instance Attribute Details

#received_encrypted_request=(value) ⇒ Object (writeonly)

Sets the attribute received_encrypted_request



25
26
27
# File 'lib/ruby_home/hap/hap_response.rb', line 25

def received_encrypted_request=(value)
  @received_encrypted_request = value
end

Instance Method Details

#send_response(socket) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ruby_home/hap/hap_response.rb', line 11

def send_response(socket)
  if encryption_time?
    response = StringIO.new
    super(response)

    encrypted_response = encrypter.encrypt(response.string).join
    cache[:accessory_to_controller_count] = encrypter.count

    _write_data(socket, encrypted_response)
  else
    super(socket)
  end
end