Permalink
Browse files

implementing tcp, udp, multicast and updating examples

  • Loading branch information...
1 parent 126e836 commit 5f9821e93efa358a2afa1cc3969afeb1219ba17b @sojamo committed Oct 30, 2013
Showing with 2,290 additions and 937 deletions.
  1. +1 −0 .gitignore
  2. +17 −0 NOTES
  3. +32 −0 examples/basics-without-comments/oscP5listener/oscP5listener.pde
  4. +48 −0 examples/basics-without-comments/oscP5parse/oscP5parse.pde
  5. +30 −0 examples/basics-without-comments/oscP5plug/oscP5plug.pde
  6. +17 −0 examples/basics-without-comments/oscP5properties/oscP5properties.pde
  7. +45 −0 examples/basics-without-comments/oscP5receive/oscP5receive.pde
  8. +33 −0 examples/basics-without-comments/oscP5send/oscP5send.pde
  9. +32 −0 examples/basics/oscP5listener/oscP5listener.pde
  10. +49 −0 examples/basics/oscP5parse/oscP5parse.pde
  11. +46 −0 examples/basics/oscP5plug/oscP5plug.pde
  12. +17 −0 examples/basics/oscP5properties/oscP5properties.pde
  13. +72 −0 examples/basics/oscP5receive/oscP5receive.pde
  14. +62 −0 examples/basics/oscP5send/oscP5send.pde
  15. 0 examples/{ → legacy}/oscP5broadcastClient/oscP5broadcastClient.pde
  16. 0 examples/{ → legacy}/oscP5broadcastTester/oscP5broadcastTester.pde
  17. 0 examples/{ → legacy}/oscP5broadcaster/oscP5broadcaster.pde
  18. 0 examples/{ → legacy}/oscP5bundle/oscP5bundle.pde
  19. 0 examples/{ → legacy}/oscP5flush/oscP5flush.pde
  20. 0 examples/{ → legacy}/oscP5message/oscP5message.pde
  21. 0 examples/{ → legacy}/oscP5multicast/oscP5multicast.pde
  22. 0 examples/{ → legacy}/oscP5oscArgument/oscP5oscArgument.pde
  23. 0 examples/{ → legacy}/oscP5parsing/oscP5parsing.pde
  24. 0 examples/{ → legacy}/oscP5plug/oscP5plug.pde
  25. 0 examples/{ → legacy}/oscP5properties/oscP5properties.pde
  26. 0 examples/{ → legacy}/oscP5sendReceive/oscP5sendReceive.pde
  27. 0 examples/{ → legacy}/oscP5tcp/oscP5tcp.pde
  28. +1 −1 pom.xml
  29. +327 −433 src/main/java/netP5/Bytes.java
  30. +184 −2 src/main/java/netP5/Multicast.java
  31. +4 −0 src/main/java/netP5/NetAddress.java
  32. +40 −0 src/main/java/netP5/NetInfo.java
  33. +38 −0 src/main/java/netP5/NetP5.java
  34. +394 −2 src/main/java/netP5/TcpClient.java
  35. +302 −2 src/main/java/netP5/TcpServer.java
  36. +18 −0 src/main/java/netP5/Transmitter.java
  37. +11 −36 src/main/java/netP5/UdpClient.java
  38. +43 −58 src/main/java/netP5/UdpServer.java
  39. +10 −0 src/main/java/netP5/changelog.txt
  40. +6 −2 src/main/java/oscP5/OscArgument.java
  41. +1 −56 src/main/java/oscP5/OscBundle.java
  42. +121 −84 src/main/java/oscP5/OscMessage.java
  43. +167 −172 src/main/java/oscP5/OscP5.java
  44. +24 −18 src/main/java/oscP5/OscPacket.java
  45. +73 −44 src/main/java/oscP5/OscPatcher.java
  46. +25 −27 src/main/java/oscP5/OscProperties.java
View
@@ -2,3 +2,4 @@ target/
.classpath
.project
.settings/
+distribution/
View
@@ -0,0 +1,17 @@
+
+ * binary hosting
+ 1) http://bintray.com
+ 2) http://www.sojamo.de/libraries/oscP5/oscP5.zip (this is where the most recent distribution is hosted which is also accessed by the PDE's Library Manager)
+ 3) code.google.com/p/oscp5/downloads (currently used as archive)
+
+ * zeroconf
+ http://stackoverflow.com/questions/1233204/are-there-any-other-java-libraries-for-bonjour-zeroconf-apart-from-jmdns
+ http://stackoverflow.com/questions/13637613/bonjour-client-java
+ http://android.noisepages.com/2010/02/yes-android-can-do-zeroconfbonjour-jmdns/
+ http://www.zeroconf.org/
+ http://jmdns.sourceforge.net/
+
+ * A list of alternative networking libraries
+ http://stackoverflow.com/questions/788786/how-to-write-a-complete-server-client-communication-using-java-nio
+
+
@@ -0,0 +1,32 @@
+import oscP5.*;
+import netP5.*;
+
+OscP5 osc;
+NetAddress receiver;
+
+void setup() {
+
+ size( 400 , 400 );
+
+ osc = new OscP5( this , 12000 );
+ receiver = new NetAddress( "127.0.0.1" , 12000 );
+
+ osc.addListener( new OscEventListener() {
+ public void oscEvent(OscMessage m) {
+ println("got a message : "+ m.getAddress() );
+ }
+ });
+
+}
+
+
+void draw() {
+ background(0);
+}
+
+void mousePressed() {
+ osc.send( receiver , "/test" , 1 , 2 , 3 );
+}
+
+
+
@@ -0,0 +1,48 @@
+import oscP5.*;
+import netP5.*;
+
+OscP5 osc;
+NetAddress receiver;
+
+void setup() {
+ size( 400 , 400 );
+ osc = new OscP5( this , 12000 );
+ receiver = new NetAddress( "127.0.0.1" , 12000 );
+
+}
+
+
+void draw() {
+ background(0);
+}
+
+void mousePressed() {
+ osc.send( receiver , "/test" , 1 , 2.0 , "three" , new byte[] {0x00 , 0x10 , 0x20 }, true , false , 100);
+}
+
+
+void oscEvent( OscMessage m) {
+
+ if( m.getAddress().equals("/test") ) {
+
+ int v0 = m.intValue( 0 );
+ float v1 = m.floatValue( 1 );
+ String v2 = m.stringValue( 2 );
+ byte[] v3 = m.bytesValue( 3 );
+ boolean v4 = m.booleanValue( 4 );
+ boolean v5 = m.booleanValue( 5 );
+ int v6 = m.intValue( 6 );
+
+ println( "Address\t" + m.getAddress() );
+
+ println( "Typetag\t" + m.getTypetag() );
+
+ println( "Arguments\t" + v0 +" , "+ v1 +" , "+ v2 +" , "+ v3 +" , "+ v4 +" , "+ v5 +" , "+v6);
+
+ for( Object o : m.getArguments() ) {
+ println( o.getClass().getSimpleName() + "\t" + o );
+ }
+
+ }
+}
+
@@ -0,0 +1,30 @@
+import oscP5.*;
+import netP5.*;
+
+OscP5 osc;
+NetAddress receiver;
+
+void setup() {
+ size(400, 400);
+
+ osc = new OscP5(this, 12000);
+ receiver = new NetAddress("127.0.0.1", 12000);
+ osc.plug(this, "test", "/test");
+}
+
+void test(float f) {
+ println("got a test "+f);
+ s0 = f;
+}
+
+float s0, s1;
+void draw() {
+ background(0);
+ s1 += (s0-s1)* 0.05;
+ ellipse( width/2, height/2, s1, s1 );
+}
+
+void mousePressed() {
+ osc.send(receiver, "/test", random( 100, 400 ) );
+}
+
@@ -0,0 +1,17 @@
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+
+void setup() {
+ size(400,400);
+ oscP5 = new OscP5(this,12000);
+ /* TODO */
+}
+
+
+void draw() {
+ background(0);
+}
+
@@ -0,0 +1,45 @@
+import oscP5.*;
+import netP5.*;
+
+OscP5 osc;
+
+NetAddress receiver;
+
+void setup() {
+ size(400,400);
+ osc = new OscP5( this , 12000 );
+ receiver = new NetAddress( "127.0.0.1" , 12000 );
+}
+
+
+float x0,x1;
+float y0,y1;
+float r0,r1;
+
+void draw() {
+ background(0);
+ x1 += (x0-x1)* 0.05;
+ y1 += (y0-y1)* 0.05;
+ r1 += (r0-r1)* 0.05;
+ translate(x1 , y1 );
+ rotate( r1 );
+ rect( 0 , 0 , 100 , 100 );
+}
+
+void mousePressed() {
+ osc.send( receiver , "/change" , random(100,300) , random(100,300) , random(-PI,PI) );
+}
+
+void oscEvent( OscMessage m ) {
+ print( "Received an osc message" );
+ print( ", address pattern: " + m.getAddress( ) );
+ print( ", typetag: " + m.getTypetag( ) );
+ if(m.getAddress( ).equals("/change") && m.getTypetag().equals("fff")) {
+ /* transfer receivd values to local variables */
+ x0 = m.floatValue(0);
+ y0 = m.floatValue(1);
+ r0 = m.floatValue(2);
+ }
+}
+
+
@@ -0,0 +1,33 @@
+import oscP5.*;
+import netP5.*;
+
+OscP5 osc;
+
+NetAddress receiver;
+
+float r,g,b;
+
+void setup() {
+ size( 400 , 400 );
+
+ osc = new OscP5( this , 12000 );
+ receiver = new NetAddress( "127.0.0.1" , 12000 );
+}
+
+void draw() {
+ background( r , g , b );
+}
+
+void mousePressed() {
+ osc.send( receiver , "/test" , random( 255 ) , random( 255 ) , random( 255 ) );
+}
+
+void oscEvent( OscMessage m ) {
+ if( m.getAddress().equals( "/test") ) {
+ r = m.floatValue( 0 );
+ g = m.floatValue( 1 );
+ b = m.floatValue( 2 );
+ }
+}
+
+
@@ -0,0 +1,32 @@
+import oscP5.*;
+import netP5.*;
+
+OscP5 osc;
+NetAddress receiver;
+
+void setup() {
+
+ size( 400 , 400 );
+
+ osc = new OscP5( this , 12000 );
+ receiver = new NetAddress( "127.0.0.1" , 12000 );
+
+ osc.addListener( new OscEventListener() {
+ public void oscEvent(OscMessage m) {
+ println("got a message : "+ m.getAddress() );
+ }
+ });
+
+}
+
+
+void draw() {
+ background(0);
+}
+
+void mousePressed() {
+ osc.send( receiver , "/test" , 1 , 2 , 3 );
+}
+
+
+
@@ -0,0 +1,49 @@
+import oscP5.*;
+import netP5.*;
+
+OscP5 osc;
+NetAddress receiver;
+
+void setup() {
+ size( 400 , 400 );
+ osc = new OscP5( this , 12000 );
+ receiver = new NetAddress( "127.0.0.1" , 12000 );
+
+}
+
+
+void draw() {
+ background(0);
+}
+
+void mousePressed() {
+ osc.send( receiver , "/test" , 1 , 2.0 , "three" , new byte[] {0x00 , 0x10 , 0x20 }, true , false , 100);
+}
+
+
+void oscEvent( OscMessage m) {
+
+ if( m.getAddress().equals("/test") ) {
+
+ int v0 = m.intValue( 0 );
+ float v1 = m.floatValue( 1 );
+ String v2 = m.stringValue( 2 );
+ byte[] v3 = m.bytesValue( 3 );
+ boolean v4 = m.booleanValue( 4 );
+ boolean v5 = m.booleanValue( 5 );
+ int v6 = m.intValue( 6 );
+
+ println( "Address\t" + m.getAddress() );
+
+ println( "Typetag\t" + m.getTypetag() );
+
+ println( "Arguments\t" + v0 +" , "+ v1 +" , "+ v2 +" , "+ v3 +" , "+ v4 +" , "+ v5 +" , "+v6);
+
+ for( Object o : m.getArguments() ) {
+ println( o.getClass().getSimpleName() + "\t" + o );
+ }
+ println();
+
+ }
+}
+
@@ -0,0 +1,46 @@
+/**
+ * oscP5plug
+ * example shows how to link an osc message to a function of an object.
+ *
+ * by Andreas Schlegel, 2013
+ * www.sojamo.de/libraries/oscP5
+ *
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 osc;
+NetAddress receiver;
+
+void setup() {
+ size(400,400);
+
+ /* start oscP5, listening for incoming messages at port 12000 */
+ osc = new OscP5(this,12000);
+
+ /* we will send osc message to ourself */
+ receiver = new NetAddress("127.0.0.1",12000);
+
+ /* plug function test of this (the main sketch object) to osc message /test */
+ osc.plug(this, "test" , "/test");
+}
+
+// expects an osc packet with address pattern /test and typetag f
+void test(float f) {
+ println("got a test "+f);
+ s0 = f; /* transfer received value to local variable */
+}
+
+float s0,s1;
+void draw() {
+ background(0);
+ s1 += (s0-s1)* 0.05;
+ ellipse( width/2 , height/2 , s1 , s1 );
+}
+
+void mousePressed() {
+ /* send an osc message to receiver */
+ osc.send(receiver, "/test" , random( 100 , 400 ) );
+}
+
@@ -0,0 +1,17 @@
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+
+void setup() {
+ size(400,400);
+ oscP5 = new OscP5(this,12000);
+ /* TODO */
+}
+
+
+void draw() {
+ background(0);
+}
+
Oops, something went wrong.

0 comments on commit 5f9821e

Please sign in to comment.