Class: RubyHome::HAP::EVResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_home/hap/ev_response.rb

Instance Method Summary collapse

Constructor Details

#initialize(session, body) ⇒ EVResponse

Returns a new instance of EVResponse.



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

def initialize(session, body)
  @session = session
  @socket = session.socket
  @body = body
end

Instance Method Details

#send_responseObject



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

def send_response
  response = ''

  send_header(response)
  send_body(response)

  encrypter = session.encrypter
  encrypted_response = encrypter.encrypt(response).join
  session.accessory_to_controller_count = encrypter.count

  socket << encrypted_response
end