Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Extract IP info from classic server as well

  • Loading branch information...
commit 3149f9ef80e34663bb661fd2cf99b5fe76718e52 1 parent 1104f17
@BrianMMcClain BrianMMcClain authored
Showing with 22 additions and 2 deletions.
  1. +18 −0 examples/classic_server_ip_info.rb
  2. +4 −2 lib/osc-ruby/server.rb
View
18 examples/classic_server_ip_info.rb
@@ -0,0 +1,18 @@
+# compatible with ruby 1.8
+$:.unshift File.join( File.dirname( __FILE__ ), '..', 'lib')
+require 'osc-ruby'
+
+@server = OSC::Server.new( 3333 )
+@client = OSC::Client.new( 'localhost', 3333 )
+
+@server.add_method '/greeting' do | message |
+ puts message.ip_address + ":" + message.ip_port.to_s + " -- " + message.address + " -- " + message.to_a.to_s
+end
+
+Thread.new do
+ @server.run
+end
+
+@client.send( OSC::Message.new( "/greeting", "hullo!" ))
+
+sleep( 3 )
View
6 lib/osc-ruby/server.rb
@@ -76,8 +76,10 @@ def detector
loop do
osc_data, network = @socket.recvfrom( 16384 )
begin
-
- OSCPacket.messages_from_network( osc_data ).each do |message|
+ ip_info = Array.new
+ ip_info << network[1]
+ ip_info.concat(network[2].split('.'))
+ OSCPacket.messages_from_network( osc_data, ip_info ).each do |message|
@queue.push(message)
end
Please sign in to comment.
Something went wrong with that request. Please try again.