Class: Chromecast::Channel::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/chromecast/channel/base.rb

Direct Known Subclasses

Connection, Heartbeat, Media, Receiver

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(connection, namespace, type) ⇒ Base

Returns a new instance of Base.



6
7
8
9
10
# File 'lib/chromecast/channel/base.rb', line 6

def initialize connection, namespace, type
  self.connection = connection
  self.namespace  = namespace
  self.type       = type
end

Instance Attribute Details

#connectionObject

Returns the value of attribute connection.



4
5
6
# File 'lib/chromecast/channel/base.rb', line 4

def connection
  @connection
end

#namespaceObject

Returns the value of attribute namespace.



4
5
6
# File 'lib/chromecast/channel/base.rb', line 4

def namespace
  @namespace
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/chromecast/channel/base.rb', line 4

def type
  @type
end

Instance Method Details

#send(data) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/chromecast/channel/base.rb', line 12

def send data
  #puts "SEND: #{data}"
  #puts ""

  msg = new_message(data)

  encoded = msg.encode
  size = [encoded.size].pack('N')

  connection.write(size + encoded)

  return nil
end