Method: Chromecast::Connection#open

Defined in:
lib/chromecast/connection.rb

#openObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/chromecast/connection.rb', line 34

def open
  tcp = TCPSocket.new(host, port)
  ctx = OpenSSL::SSL::SSLContext.new
  ctx.cert = OpenSSL::X509::Certificate.new(certificate(:crt))
  ctx.key = OpenSSL::PKey::RSA.new(certificate(:key))
  ctx.ssl_version = :SSLv23
  ctx.set_params(verify_mode: OpenSSL::SSL::VERIFY_NONE)

  @socket = OpenSSL::SSL::SSLSocket.new(tcp, ctx).tap do |socket|
    socket.sync_close = true
    socket.connect
  end

  self
end