Class: Arcenciel::Hub

Inherits:
Object
  • Object
show all
Defined in:
lib/arcenciel/manager/hub.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHub

Returns a new instance of Hub.



11
12
13
14
15
16
17
# File 'lib/arcenciel/manager/hub.rb', line 11

def initialize
  @serial_port = 12002
  @server_port = 10210

  @client = OSC::Client.new('localhost', serial_port)
  @server = OSC::Server.new(server_port)
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



8
9
10
# File 'lib/arcenciel/manager/hub.rb', line 8

def client
  @client
end

#serial_portObject (readonly)

Returns the value of attribute serial_port.



5
6
7
# File 'lib/arcenciel/manager/hub.rb', line 5

def serial_port
  @serial_port
end

#serverObject (readonly)

Returns the value of attribute server.



9
10
11
# File 'lib/arcenciel/manager/hub.rb', line 9

def server
  @server
end

#server_portObject (readonly)

Returns the value of attribute server_port.



6
7
8
# File 'lib/arcenciel/manager/hub.rb', line 6

def server_port
  @server_port
end

Instance Method Details

#listen(path, &blk) ⇒ Object



29
30
31
# File 'lib/arcenciel/manager/hub.rb', line 29

def listen(path, &blk)
  server.add_method(path, &blk)
end

#run!Object



19
20
21
22
23
# File 'lib/arcenciel/manager/hub.rb', line 19

def run!
  Thread.start do
    server.run
  end
end

#send(command) ⇒ Object



25
26
27
# File 'lib/arcenciel/manager/hub.rb', line 25

def send(command)
  client.send(OSC::Message.new(command, 'localhost', server_port))
end