Permalink
Browse files

Extract IP info from classic server as well

  • Loading branch information...
BrianMMcClain committed Mar 18, 2012
1 parent 1104f17 commit 3149f9ef80e34663bb661fd2cf99b5fe76718e52
Showing with 22 additions and 2 deletions.
  1. +18 −0 examples/classic_server_ip_info.rb
  2. +4 −2 lib/osc-ruby/server.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
@@ -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

0 comments on commit 3149f9e

Please sign in to comment.