Class: Patch::IO::OSC::Server
- Inherits:
-
Object
- Object
- Patch::IO::OSC::Server
- Defined in:
- lib/patch/io/osc/server.rb
Overview
OSC server
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#active? ⇒ Boolean
Is the server active?.
-
#disable(patch) ⇒ Boolean
Disable the message handlers.
-
#initialize(id, port, options = {}) ⇒ Server
constructor
A new instance of Server.
-
#listen(patch, &callback) ⇒ Boolean
Listen for messages.
-
#start ⇒ Boolean
Start the server.
-
#stop ⇒ Boolean
Stop the server.
Constructor Details
#initialize(id, port, options = {}) ⇒ Server
Returns a new instance of Server.
17 18 19 20 21 22 23 24 25 |
# File 'lib/patch/io/osc/server.rb', line 17 def initialize(id, port, = {}) @log = [:log] @server = nil @active = false @id = id @is_failsafe = true configure(port, ) end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/patch/io/osc/server.rb', line 10 def id @id end |
Instance Method Details
#active? ⇒ Boolean
Is the server active?
29 30 31 |
# File 'lib/patch/io/osc/server.rb', line 29 def active? @active end |
#disable(patch) ⇒ Boolean
Disable the message handlers
50 51 52 53 |
# File 'lib/patch/io/osc/server.rb', line 50 def disable(patch) addresses = get_addresses(patch) addresses.select { |address| @server.remove_method(address) }.any? end |
#listen(patch, &callback) ⇒ Boolean
Listen for messages
59 60 61 62 |
# File 'lib/patch/io/osc/server.rb', line 59 def listen(patch, &callback) addresses = get_addresses(patch) addresses.select { |address| listen_for(address, patch, &callback) }.any? end |
#start ⇒ Boolean
Start the server
35 36 37 38 39 |
# File 'lib/patch/io/osc/server.rb', line 35 def start @active = true @connection = @server.run true end |
#stop ⇒ Boolean
Stop the server
43 44 45 46 |
# File 'lib/patch/io/osc/server.rb', line 43 def stop @active = false true end |