Class: OSCAccess::Emitter

Inherits:
Object
  • Object
show all
Defined in:
lib/osc-access/emitter.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize ⇒ Emitter

Returns a new instance of Emitter.



8
9
10
# File 'lib/osc-access/emitter.rb', line 8

def initialize
  @clients = []
end

Instance Attribute Details

#clients ⇒ Object (readonly)

Returns the value of attribute clients.



6
7
8
# File 'lib/osc-access/emitter.rb', line 6

def clients
  @clients
end

Class Method Details

.client(host, port) ⇒ Object



21
22
23
24
25
26
# File 'lib/osc-access/emitter.rb', line 21

def self.client(host, port)
  @clients ||= {}
  @clients[host] ||= {}
  @clients[host][port] ||= OSC::Client.new(host, port)
  @clients[host][port]
end

Instance Method Details

#add_client(host, port) ⇒ Object



12
13
14
# File 'lib/osc-access/emitter.rb', line 12

def add_client(host, port)
  @clients << self.class.client(host, port)
end

#transmit(*a) ⇒ Object



16
17
18
19
# File 'lib/osc-access/emitter.rb', line 16

def transmit(*a)
  msg = a.first.kind_of?(OSC::Message) ? a.first : OSC::Message.new(*a)
  @clients.each { |c| c.send(msg) }
end