Class: GoogleAnymote::TV
- Inherits:
-
Object
- Object
- GoogleAnymote::TV
- Defined in:
- lib/google_anymote/tv.rb
Overview
Class to send events to a connected GoogleTV
Instance Attribute Summary collapse
-
#cert ⇒ Object
readonly
Returns the value of attribute cert.
-
#cotext ⇒ Object
readonly
Returns the value of attribute cotext.
-
#fling ⇒ Object
readonly
Returns the value of attribute fling.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
-
#request ⇒ Object
readonly
Returns the value of attribute request.
-
#ssl_client ⇒ Object
readonly
Returns the value of attribute ssl_client.
Instance Method Summary collapse
-
#connect_to_unit ⇒ Object
Connect this object to a Google TV.
-
#finalize ⇒ Object
Clean up any sockets or other garbage.
-
#fling_uri(uri) ⇒ Object
Fling a URI to the Google TV connected to this object.
-
#initialize(cert, host, port = 9551) ⇒ Object
constructor
Initializes the TV class.
Constructor Details
#initialize(cert, host, port = 9551) ⇒ Object
Initializes the TV class.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/google_anymote/tv.rb', line 20 def initialize(cert, host, port = 9551) @host = host @port = port @cert = cert @remote = RemoteMessage.new @request = RequestMessage.new @fling = Fling.new # Build the SSL stuff @context = OpenSSL::SSL::SSLContext.new @context.key = OpenSSL::PKey::RSA.new @cert @context.cert = OpenSSL::X509::Certificate.new @cert connect_to_unit end |
Instance Attribute Details
#cert ⇒ Object (readonly)
Returns the value of attribute cert.
11 12 13 |
# File 'lib/google_anymote/tv.rb', line 11 def cert @cert end |
#cotext ⇒ Object (readonly)
Returns the value of attribute cotext.
11 12 13 |
# File 'lib/google_anymote/tv.rb', line 11 def cotext @cotext end |
#fling ⇒ Object (readonly)
Returns the value of attribute fling.
11 12 13 |
# File 'lib/google_anymote/tv.rb', line 11 def fling @fling end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
11 12 13 |
# File 'lib/google_anymote/tv.rb', line 11 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
11 12 13 |
# File 'lib/google_anymote/tv.rb', line 11 def port @port end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
11 12 13 |
# File 'lib/google_anymote/tv.rb', line 11 def remote @remote end |
#request ⇒ Object (readonly)
Returns the value of attribute request.
11 12 13 |
# File 'lib/google_anymote/tv.rb', line 11 def request @request end |
#ssl_client ⇒ Object (readonly)
Returns the value of attribute ssl_client.
11 12 13 |
# File 'lib/google_anymote/tv.rb', line 11 def ssl_client @ssl_client end |
Instance Method Details
#connect_to_unit ⇒ Object
Connect this object to a Google TV
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/google_anymote/tv.rb', line 38 def connect_to_unit puts "Connecting to '#{@host}..." begin tcp_client = TCPSocket.new @host, @port @ssl_client = OpenSSL::SSL::SSLSocket.new tcp_client, @context @ssl_client.connect rescue Exception => e puts "Could not connect to '#{@host}: #{e}" end end |
#finalize ⇒ Object
Clean up any sockets or other garbage.
51 52 53 |
# File 'lib/google_anymote/tv.rb', line 51 def finalize() @ssl_client.close end |
#fling_uri(uri) ⇒ Object
Fling a URI to the Google TV connected to this object
57 58 59 60 61 62 |
# File 'lib/google_anymote/tv.rb', line 57 def fling_uri(uri) @fling.uri = uri @request. = fling @remote. = @request (@remote) end |