From 589e6c881bd2cf11e8615e9c1bf8cb4012293bad Mon Sep 17 00:00:00 2001 From: David Runge Date: Thu, 31 Dec 2015 03:34:08 +0100 Subject: libraries/oscP5: Adding oscP5 library for OSC capabilities. --- .../oscP5broadcastClient/oscP5broadcastClient.pde | 73 + .../oscP5broadcastTester/oscP5broadcastTester.pde | 27 + .../examples/oscP5broadcaster/oscP5broadcaster.pde | 73 + .../oscP5/examples/oscP5bundle/oscP5bundle.pde | 69 + libraries/oscP5/examples/oscP5flush/oscP5flush.pde | 38 + .../oscP5/examples/oscP5message/oscP5message.pde | 55 + .../examples/oscP5multicast/oscP5multicast.pde | 51 + .../examples/oscP5oscArgument/oscP5oscArgument.pde | 45 + .../oscP5/examples/oscP5parsing/oscP5parsing.pde | 65 + libraries/oscP5/examples/oscP5plug/oscP5plug.pde | 82 + .../examples/oscP5properties/oscP5properties.pde | 72 + .../examples/oscP5sendReceive/oscP5sendReceive.pde | 51 + libraries/oscP5/examples/oscP5tcp/oscP5tcp.pde | 59 + libraries/oscP5/library.properties | 44 + libraries/oscP5/library/oscP5.jar | Bin 0 -> 52021 bytes libraries/oscP5/reference/allclasses-frame.html | 99 ++ libraries/oscP5/reference/allclasses-noframe.html | 99 ++ libraries/oscP5/reference/constant-values.html | 446 +++++ libraries/oscP5/reference/deprecated-list.html | 229 +++ libraries/oscP5/reference/help-doc.html | 217 +++ libraries/oscP5/reference/index-all.html | 1692 ++++++++++++++++++ libraries/oscP5/reference/index.html | 39 + .../oscP5/reference/netP5/AbstractMulticast.html | 560 ++++++ .../oscP5/reference/netP5/AbstractTcpClient.html | 869 ++++++++++ .../oscP5/reference/netP5/AbstractTcpServer.html | 675 ++++++++ .../oscP5/reference/netP5/AbstractUdpClient.html | 408 +++++ .../oscP5/reference/netP5/AbstractUdpServer.html | 440 +++++ libraries/oscP5/reference/netP5/Bytes.html | 906 ++++++++++ libraries/oscP5/reference/netP5/Logger.html | 613 +++++++ libraries/oscP5/reference/netP5/Multicast.html | 428 +++++ libraries/oscP5/reference/netP5/NetAddress.html | 422 +++++ .../oscP5/reference/netP5/NetAddressList.html | 460 +++++ libraries/oscP5/reference/netP5/NetInfo.html | 334 ++++ libraries/oscP5/reference/netP5/NetListener.html | 223 +++ libraries/oscP5/reference/netP5/NetMessage.html | 386 +++++ libraries/oscP5/reference/netP5/NetP5.html | 274 +++ libraries/oscP5/reference/netP5/NetStatus.html | 434 +++++ libraries/oscP5/reference/netP5/StringUtils.html | 1008 +++++++++++ libraries/oscP5/reference/netP5/TcpClient.html | 473 +++++ libraries/oscP5/reference/netP5/TcpPacket.html | 311 ++++ .../oscP5/reference/netP5/TcpPacketListener.html | 247 +++ libraries/oscP5/reference/netP5/TcpServer.html | 463 +++++ libraries/oscP5/reference/netP5/UdpClient.html | 266 +++ .../oscP5/reference/netP5/UdpPacketListener.html | 213 +++ libraries/oscP5/reference/netP5/UdpServer.html | 411 +++++ libraries/oscP5/reference/netP5/package-frame.html | 85 + .../oscP5/reference/netP5/package-summary.html | 255 +++ libraries/oscP5/reference/netP5/package-tree.html | 172 ++ libraries/oscP5/reference/oscP5/OscArgument.html | 1160 +++++++++++++ libraries/oscP5/reference/oscP5/OscBundle.html | 765 +++++++++ .../oscP5/reference/oscP5/OscEventListener.html | 223 +++ libraries/oscP5/reference/oscP5/OscIn.html | 434 +++++ libraries/oscP5/reference/oscP5/OscMessage.html | 1447 ++++++++++++++++ libraries/oscP5/reference/oscP5/OscNetManager.html | 760 ++++++++ libraries/oscP5/reference/oscP5/OscP5.html | 1807 ++++++++++++++++++++ libraries/oscP5/reference/oscP5/OscPacket.html | 357 ++++ libraries/oscP5/reference/oscP5/OscPatcher.html | 192 +++ libraries/oscP5/reference/oscP5/OscPlug.html | 393 +++++ libraries/oscP5/reference/oscP5/OscProperties.html | 799 +++++++++ libraries/oscP5/reference/oscP5/OscStatus.html | 448 +++++ libraries/oscP5/reference/oscP5/package-frame.html | 63 + .../oscP5/reference/oscP5/package-summary.html | 211 +++ libraries/oscP5/reference/oscP5/package-tree.html | 164 ++ libraries/oscP5/reference/overview-frame.html | 44 + libraries/oscP5/reference/overview-summary.html | 158 ++ libraries/oscP5/reference/overview-tree.html | 179 ++ libraries/oscP5/reference/package-list | 2 + libraries/oscP5/reference/resources/inherit.gif | Bin 0 -> 57 bytes libraries/oscP5/reference/stylesheet.css | 310 ++++ libraries/oscP5/src/netP5/AbstractMulticast.java | 337 ++++ libraries/oscP5/src/netP5/AbstractTcpClient.java | 491 ++++++ libraries/oscP5/src/netP5/AbstractTcpServer.java | 317 ++++ libraries/oscP5/src/netP5/AbstractUdpClient.java | 199 +++ libraries/oscP5/src/netP5/AbstractUdpServer.java | 271 +++ libraries/oscP5/src/netP5/Bytes.java | 470 +++++ libraries/oscP5/src/netP5/Logger.java | 153 ++ libraries/oscP5/src/netP5/Multicast.java | 116 ++ libraries/oscP5/src/netP5/NetAddress.java | 130 ++ libraries/oscP5/src/netP5/NetAddressList.java | 169 ++ libraries/oscP5/src/netP5/NetInfo.java | 154 ++ libraries/oscP5/src/netP5/NetListener.java | 34 + libraries/oscP5/src/netP5/NetMessage.java | 148 ++ libraries/oscP5/src/netP5/NetP5.java | 55 + libraries/oscP5/src/netP5/NetPlug.java | 222 +++ libraries/oscP5/src/netP5/NetStatus.java | 65 + libraries/oscP5/src/netP5/StringUtils.java | 705 ++++++++ libraries/oscP5/src/netP5/TcpClient.java | 214 +++ libraries/oscP5/src/netP5/TcpPacket.java | 67 + libraries/oscP5/src/netP5/TcpPacketListener.java | 38 + libraries/oscP5/src/netP5/TcpServer.java | 177 ++ libraries/oscP5/src/netP5/UdpClient.java | 49 + libraries/oscP5/src/netP5/UdpPacketListener.java | 41 + libraries/oscP5/src/netP5/UdpServer.java | 151 ++ libraries/oscP5/src/oscP5/OscArgument.java | 228 +++ libraries/oscP5/src/oscP5/OscBundle.java | 189 ++ libraries/oscP5/src/oscP5/OscEventListener.java | 37 + libraries/oscP5/src/oscP5/OscIn.java | 89 + libraries/oscP5/src/oscP5/OscMessage.java | 764 +++++++++ libraries/oscP5/src/oscP5/OscNetManager.java | 386 +++++ libraries/oscP5/src/oscP5/OscP5.java | 991 +++++++++++ libraries/oscP5/src/oscP5/OscPacket.java | 143 ++ libraries/oscP5/src/oscP5/OscPatcher.java | 245 +++ libraries/oscP5/src/oscP5/OscPlug.java | 258 +++ libraries/oscP5/src/oscP5/OscProperties.java | 319 ++++ libraries/oscP5/src/oscP5/OscStatus.java | 63 + 105 files changed, 33362 insertions(+) create mode 100644 libraries/oscP5/examples/oscP5broadcastClient/oscP5broadcastClient.pde create mode 100644 libraries/oscP5/examples/oscP5broadcastTester/oscP5broadcastTester.pde create mode 100644 libraries/oscP5/examples/oscP5broadcaster/oscP5broadcaster.pde create mode 100644 libraries/oscP5/examples/oscP5bundle/oscP5bundle.pde create mode 100644 libraries/oscP5/examples/oscP5flush/oscP5flush.pde create mode 100644 libraries/oscP5/examples/oscP5message/oscP5message.pde create mode 100644 libraries/oscP5/examples/oscP5multicast/oscP5multicast.pde create mode 100644 libraries/oscP5/examples/oscP5oscArgument/oscP5oscArgument.pde create mode 100644 libraries/oscP5/examples/oscP5parsing/oscP5parsing.pde create mode 100644 libraries/oscP5/examples/oscP5plug/oscP5plug.pde create mode 100644 libraries/oscP5/examples/oscP5properties/oscP5properties.pde create mode 100644 libraries/oscP5/examples/oscP5sendReceive/oscP5sendReceive.pde create mode 100644 libraries/oscP5/examples/oscP5tcp/oscP5tcp.pde create mode 100644 libraries/oscP5/library.properties create mode 100644 libraries/oscP5/library/oscP5.jar create mode 100644 libraries/oscP5/reference/allclasses-frame.html create mode 100644 libraries/oscP5/reference/allclasses-noframe.html create mode 100644 libraries/oscP5/reference/constant-values.html create mode 100644 libraries/oscP5/reference/deprecated-list.html create mode 100644 libraries/oscP5/reference/help-doc.html create mode 100644 libraries/oscP5/reference/index-all.html create mode 100644 libraries/oscP5/reference/index.html create mode 100644 libraries/oscP5/reference/netP5/AbstractMulticast.html create mode 100644 libraries/oscP5/reference/netP5/AbstractTcpClient.html create mode 100644 libraries/oscP5/reference/netP5/AbstractTcpServer.html create mode 100644 libraries/oscP5/reference/netP5/AbstractUdpClient.html create mode 100644 libraries/oscP5/reference/netP5/AbstractUdpServer.html create mode 100644 libraries/oscP5/reference/netP5/Bytes.html create mode 100644 libraries/oscP5/reference/netP5/Logger.html create mode 100644 libraries/oscP5/reference/netP5/Multicast.html create mode 100644 libraries/oscP5/reference/netP5/NetAddress.html create mode 100644 libraries/oscP5/reference/netP5/NetAddressList.html create mode 100644 libraries/oscP5/reference/netP5/NetInfo.html create mode 100644 libraries/oscP5/reference/netP5/NetListener.html create mode 100644 libraries/oscP5/reference/netP5/NetMessage.html create mode 100644 libraries/oscP5/reference/netP5/NetP5.html create mode 100644 libraries/oscP5/reference/netP5/NetStatus.html create mode 100644 libraries/oscP5/reference/netP5/StringUtils.html create mode 100644 libraries/oscP5/reference/netP5/TcpClient.html create mode 100644 libraries/oscP5/reference/netP5/TcpPacket.html create mode 100644 libraries/oscP5/reference/netP5/TcpPacketListener.html create mode 100644 libraries/oscP5/reference/netP5/TcpServer.html create mode 100644 libraries/oscP5/reference/netP5/UdpClient.html create mode 100644 libraries/oscP5/reference/netP5/UdpPacketListener.html create mode 100644 libraries/oscP5/reference/netP5/UdpServer.html create mode 100644 libraries/oscP5/reference/netP5/package-frame.html create mode 100644 libraries/oscP5/reference/netP5/package-summary.html create mode 100644 libraries/oscP5/reference/netP5/package-tree.html create mode 100644 libraries/oscP5/reference/oscP5/OscArgument.html create mode 100644 libraries/oscP5/reference/oscP5/OscBundle.html create mode 100644 libraries/oscP5/reference/oscP5/OscEventListener.html create mode 100644 libraries/oscP5/reference/oscP5/OscIn.html create mode 100644 libraries/oscP5/reference/oscP5/OscMessage.html create mode 100644 libraries/oscP5/reference/oscP5/OscNetManager.html create mode 100644 libraries/oscP5/reference/oscP5/OscP5.html create mode 100644 libraries/oscP5/reference/oscP5/OscPacket.html create mode 100644 libraries/oscP5/reference/oscP5/OscPatcher.html create mode 100644 libraries/oscP5/reference/oscP5/OscPlug.html create mode 100644 libraries/oscP5/reference/oscP5/OscProperties.html create mode 100644 libraries/oscP5/reference/oscP5/OscStatus.html create mode 100644 libraries/oscP5/reference/oscP5/package-frame.html create mode 100644 libraries/oscP5/reference/oscP5/package-summary.html create mode 100644 libraries/oscP5/reference/oscP5/package-tree.html create mode 100644 libraries/oscP5/reference/overview-frame.html create mode 100644 libraries/oscP5/reference/overview-summary.html create mode 100644 libraries/oscP5/reference/overview-tree.html create mode 100644 libraries/oscP5/reference/package-list create mode 100644 libraries/oscP5/reference/resources/inherit.gif create mode 100644 libraries/oscP5/reference/stylesheet.css create mode 100644 libraries/oscP5/src/netP5/AbstractMulticast.java create mode 100644 libraries/oscP5/src/netP5/AbstractTcpClient.java create mode 100644 libraries/oscP5/src/netP5/AbstractTcpServer.java create mode 100644 libraries/oscP5/src/netP5/AbstractUdpClient.java create mode 100644 libraries/oscP5/src/netP5/AbstractUdpServer.java create mode 100644 libraries/oscP5/src/netP5/Bytes.java create mode 100644 libraries/oscP5/src/netP5/Logger.java create mode 100644 libraries/oscP5/src/netP5/Multicast.java create mode 100644 libraries/oscP5/src/netP5/NetAddress.java create mode 100644 libraries/oscP5/src/netP5/NetAddressList.java create mode 100644 libraries/oscP5/src/netP5/NetInfo.java create mode 100644 libraries/oscP5/src/netP5/NetListener.java create mode 100644 libraries/oscP5/src/netP5/NetMessage.java create mode 100644 libraries/oscP5/src/netP5/NetP5.java create mode 100644 libraries/oscP5/src/netP5/NetPlug.java create mode 100644 libraries/oscP5/src/netP5/NetStatus.java create mode 100644 libraries/oscP5/src/netP5/StringUtils.java create mode 100644 libraries/oscP5/src/netP5/TcpClient.java create mode 100644 libraries/oscP5/src/netP5/TcpPacket.java create mode 100644 libraries/oscP5/src/netP5/TcpPacketListener.java create mode 100644 libraries/oscP5/src/netP5/TcpServer.java create mode 100644 libraries/oscP5/src/netP5/UdpClient.java create mode 100644 libraries/oscP5/src/netP5/UdpPacketListener.java create mode 100644 libraries/oscP5/src/netP5/UdpServer.java create mode 100644 libraries/oscP5/src/oscP5/OscArgument.java create mode 100644 libraries/oscP5/src/oscP5/OscBundle.java create mode 100644 libraries/oscP5/src/oscP5/OscEventListener.java create mode 100644 libraries/oscP5/src/oscP5/OscIn.java create mode 100644 libraries/oscP5/src/oscP5/OscMessage.java create mode 100644 libraries/oscP5/src/oscP5/OscNetManager.java create mode 100644 libraries/oscP5/src/oscP5/OscP5.java create mode 100644 libraries/oscP5/src/oscP5/OscPacket.java create mode 100644 libraries/oscP5/src/oscP5/OscPatcher.java create mode 100644 libraries/oscP5/src/oscP5/OscPlug.java create mode 100644 libraries/oscP5/src/oscP5/OscProperties.java create mode 100644 libraries/oscP5/src/oscP5/OscStatus.java (limited to 'libraries') diff --git a/libraries/oscP5/examples/oscP5broadcastClient/oscP5broadcastClient.pde b/libraries/oscP5/examples/oscP5broadcastClient/oscP5broadcastClient.pde new file mode 100644 index 0000000..56fb843 --- /dev/null +++ b/libraries/oscP5/examples/oscP5broadcastClient/oscP5broadcastClient.pde @@ -0,0 +1,73 @@ +/** + * oscP5broadcastClient by andreas schlegel + * an osc broadcast client. + * an example for broadcast server is located in the oscP5broadcaster exmaple. + * oscP5 website at http://www.sojamo.de/oscP5 + */ + +import oscP5.*; +import netP5.*; + + +OscP5 oscP5; + +/* a NetAddress contains the ip address and port number of a remote location in the network. */ +NetAddress myBroadcastLocation; + +void setup() { + size(400,400); + frameRate(25); + + /* create a new instance of oscP5. + * 12000 is the port number you are listening for incoming osc messages. + */ + oscP5 = new OscP5(this,12000); + + /* create a new NetAddress. a NetAddress is used when sending osc messages + * with the oscP5.send method. + */ + + /* the address of the osc broadcast server */ + myBroadcastLocation = new NetAddress("127.0.0.1",32000); +} + + +void draw() { + background(0); +} + + +void mousePressed() { + /* create a new OscMessage with an address pattern, in this case /test. */ + OscMessage myOscMessage = new OscMessage("/test"); + /* add a value (an integer) to the OscMessage */ + myOscMessage.add(100); + /* send the OscMessage to a remote location specified in myNetAddress */ + oscP5.send(myOscMessage, myBroadcastLocation); +} + + +void keyPressed() { + OscMessage m; + switch(key) { + case('c'): + /* connect to the broadcaster */ + m = new OscMessage("/server/connect",new Object[0]); + oscP5.flush(m,myBroadcastLocation); + break; + case('d'): + /* disconnect from the broadcaster */ + m = new OscMessage("/server/disconnect",new Object[0]); + oscP5.flush(m,myBroadcastLocation); + break; + + } +} + + +/* incoming osc message are forwarded to the oscEvent method. */ +void oscEvent(OscMessage theOscMessage) { + /* get and print the address pattern and the typetag of the received OscMessage */ + println("### received an osc message with addrpattern "+theOscMessage.addrPattern()+" and typetag "+theOscMessage.typetag()); + theOscMessage.print(); +} diff --git a/libraries/oscP5/examples/oscP5broadcastTester/oscP5broadcastTester.pde b/libraries/oscP5/examples/oscP5broadcastTester/oscP5broadcastTester.pde new file mode 100644 index 0000000..440e7cd --- /dev/null +++ b/libraries/oscP5/examples/oscP5broadcastTester/oscP5broadcastTester.pde @@ -0,0 +1,27 @@ +import controlP5.*; + + +ControlP5 controlP5; + +int myColorBackground = color(0,0,0); + +int knobValue = 100; + +void setup() { + size(400,400); + smooth(); + controlP5 = new ControlP5(this); + controlP5.addKnob("knob",100,200,128,100,160,40); + controlP5.addKnob("knobValue",0,255,128,100,240,40); +} + +void draw() { + background(myColorBackground); + fill(knobValue); + rect(0,0,width,100); +} + +void knob(int theColor) { + myColorBackground = color(theColor); + println("a knob event. setting background to "+theColor); +} diff --git a/libraries/oscP5/examples/oscP5broadcaster/oscP5broadcaster.pde b/libraries/oscP5/examples/oscP5broadcaster/oscP5broadcaster.pde new file mode 100644 index 0000000..1cbd638 --- /dev/null +++ b/libraries/oscP5/examples/oscP5broadcaster/oscP5broadcaster.pde @@ -0,0 +1,73 @@ +/** + * oscP5broadcaster by andreas schlegel + * an osc broadcast server. + * osc clients can connect to the server by sending a connect and + * disconnect osc message as defined below to the server. + * incoming messages at the server will then be broadcasted to + * all connected clients. + * an example for a client is located in the oscP5broadcastClient exmaple. + * oscP5 website at http://www.sojamo.de/oscP5 + */ + +import oscP5.*; +import netP5.*; + +OscP5 oscP5; +NetAddressList myNetAddressList = new NetAddressList(); +/* listeningPort is the port the server is listening for incoming messages */ +int myListeningPort = 32000; +/* the broadcast port is the port the clients should listen for incoming messages from the server*/ +int myBroadcastPort = 12000; + +String myConnectPattern = "/server/connect"; +String myDisconnectPattern = "/server/disconnect"; + + +void setup() { + oscP5 = new OscP5(this, myListeningPort); + frameRate(25); +} + +void draw() { + background(0); +} + +void oscEvent(OscMessage theOscMessage) { + /* check if the address pattern fits any of our patterns */ + if (theOscMessage.addrPattern().equals(myConnectPattern)) { + connect(theOscMessage.netAddress().address()); + } + else if (theOscMessage.addrPattern().equals(myDisconnectPattern)) { + disconnect(theOscMessage.netAddress().address()); + } + /** + * if pattern matching was not successful, then broadcast the incoming + * message to all addresses in the netAddresList. + */ + else { + oscP5.send(theOscMessage, myNetAddressList); + } +} + + + private void connect(String theIPaddress) { + if (!myNetAddressList.contains(theIPaddress, myBroadcastPort)) { + myNetAddressList.add(new NetAddress(theIPaddress, myBroadcastPort)); + println("### adding "+theIPaddress+" to the list."); + } else { + println("### "+theIPaddress+" is already connected."); + } + println("### currently there are "+myNetAddressList.list().size()+" remote locations connected."); + } + + + +private void disconnect(String theIPaddress) { +if (myNetAddressList.contains(theIPaddress, myBroadcastPort)) { + myNetAddressList.remove(theIPaddress, myBroadcastPort); + println("### removing "+theIPaddress+" from the list."); + } else { + println("### "+theIPaddress+" is not connected."); + } + println("### currently there are "+myNetAddressList.list().size()); + } diff --git a/libraries/oscP5/examples/oscP5bundle/oscP5bundle.pde b/libraries/oscP5/examples/oscP5bundle/oscP5bundle.pde new file mode 100644 index 0000000..a747db2 --- /dev/null +++ b/libraries/oscP5/examples/oscP5bundle/oscP5bundle.pde @@ -0,0 +1,69 @@ +/** + * oscP5bundle by andreas schlegel + * an osc broadcast server. + * example shows how to create and send osc bundles. + * oscP5 website at http://www.sojamo.de/oscP5 + */ + +import oscP5.*; +import netP5.*; + +OscP5 oscP5; +NetAddress myRemoteLocation; + +void setup() { + size(400,400); + frameRate(25); + /* start oscP5, listening for incoming messages at port 12000 */ + oscP5 = new OscP5(this,12000); + + /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters, + * an ip address and a port number. myRemoteLocation is used as parameter in + * oscP5.send() when sending osc packets to another computer, device, + * application. usage see below. for testing purposes the listening port + * and the port of the remote location address are the same, hence you will + * send messages back to this sketch. + */ + myRemoteLocation = new NetAddress("127.0.0.1",12000); +} + + +void draw() { + background(0); +} + + +void mousePressed() { + /* create an osc bundle */ + OscBundle myBundle = new OscBundle(); + + /* createa new osc message object */ + OscMessage myMessage = new OscMessage("/test"); + myMessage.add("abc"); + + /* add an osc message to the osc bundle */ + myBundle.add(myMessage); + + /* reset and clear the myMessage object for refill. */ + myMessage.clear(); + + /* refill the osc message object again */ + myMessage.setAddrPattern("/test2"); + myMessage.add("defg"); + myBundle.add(myMessage); + + myBundle.setTimetag(myBundle.now() + 10000); + /* send the osc bundle, containing 2 osc messages, to a remote location. */ + oscP5.send(myBundle, myRemoteLocation); +} + + + +/* incoming osc message are forwarded to the oscEvent method. */ +void oscEvent(OscMessage theOscMessage) { + /* print the address pattern and the typetag of the received OscMessage */ + print("### received an osc message."); + print(" addrpattern: "+theOscMessage.addrPattern()); + print(" typetag: "+theOscMessage.typetag()); + println(" timetag: "+theOscMessage.timetag()); +} diff --git a/libraries/oscP5/examples/oscP5flush/oscP5flush.pde b/libraries/oscP5/examples/oscP5flush/oscP5flush.pde new file mode 100644 index 0000000..e6e8147 --- /dev/null +++ b/libraries/oscP5/examples/oscP5flush/oscP5flush.pde @@ -0,0 +1,38 @@ + /** + * oscP5flush by andreas schlegel + * example shows how to send osc messages without having to instantiate an oscP5 object. + * this can be useful if you are not listening for incoming messages and you + * want to avoid to have the additional oscP5 thread running listening for incoming + * message (which you wont need if you are only sending messages). + * oscP5 website at http://www.sojamo.de/oscP5 + */ + +import oscP5.*; +import netP5.*; + + +NetAddress myRemoteLocation; +void setup() { + size(400,400); + frameRate(25); + /* set up a remote location */ + myRemoteLocation = new NetAddress("127.0.0.1",12000); +} + + +void draw() { + background(0); +} + + +void mousePressed() { + /* create a new OscMessage with an address pattern, in this case /test. */ + OscMessage myOscMessage = new OscMessage("/test"); + + /* add a value (an integer) to the OscMessage */ + myOscMessage.add(100); + + /* send the OscMessage to the remote location. + */ + OscP5.flush(myOscMessage,myRemoteLocation); +} diff --git a/libraries/oscP5/examples/oscP5message/oscP5message.pde b/libraries/oscP5/examples/oscP5message/oscP5message.pde new file mode 100644 index 0000000..b19f38f --- /dev/null +++ b/libraries/oscP5/examples/oscP5message/oscP5message.pde @@ -0,0 +1,55 @@ +/** + * oscP5message by andreas schlegel + * example shows how to create osc messages. + * oscP5 website at http://www.sojamo.de/oscP5 + */ + +import oscP5.*; +import netP5.*; + +OscP5 oscP5; +NetAddress myRemoteLocation; + +void setup() { + size(400,400); + frameRate(25); + /* start oscP5, listening for incoming messages at port 12000 */ + oscP5 = new OscP5(this,12000); + + /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters, + * an ip address and a port number. myRemoteLocation is used as parameter in + * oscP5.send() when sending osc packets to another computer, device, + * application. usage see below. for testing purposes the listening port + * and the port of the remote location address are the same, hence you will + * send messages back to this sketch. + */ + myRemoteLocation = new NetAddress("127.0.0.1",12000); +} + + +void draw() { + background(0); +} + +void mousePressed() { + /* in the following different ways of creating osc messages are shown by example */ + OscMessage myMessage = new OscMessage("/test"); + + myMessage.add(123); /* add an int to the osc message */ + myMessage.add(12.34); /* add a float to the osc message */ + myMessage.add("some text"); /* add a string to the osc message */ + myMessage.add(new byte[] {0x00, 0x01, 0x10, 0x20}); /* add a byte blob to the osc message */ + myMessage.add(new int[] {1,2,3,4}); /* add an int array to the osc message */ + + /* send the message */ + oscP5.send(myMessage, myRemoteLocation); +} + + +/* incoming osc message are forwarded to the oscEvent method. */ +void oscEvent(OscMessage theOscMessage) { + /* print the address pattern and the typetag of the received OscMessage */ + print("### received an osc message."); + print(" addrpattern: "+theOscMessage.addrPattern()); + println(" typetag: "+theOscMessage.typetag()); +} diff --git a/libraries/oscP5/examples/oscP5multicast/oscP5multicast.pde b/libraries/oscP5/examples/oscP5multicast/oscP5multicast.pde new file mode 100644 index 0000000..26d6dc1 --- /dev/null +++ b/libraries/oscP5/examples/oscP5multicast/oscP5multicast.pde @@ -0,0 +1,51 @@ +/** + * oscP5multicast by andreas schlegel + * example shows how to send osc via a multicast socket. + * what is a multicast? http://en.wikipedia.org/wiki/Multicast + * ip multicast ranges and uses: + * 224.0.0.0 - 224.0.0.255 Reserved for special Òwell-knownÓ multicast addresses. + * 224.0.1.0 - 238.255.255.255 Globally-scoped (Internet-wide) multicast addresses. + * 239.0.0.0 - 239.255.255.255 Administratively-scoped (local) multicast addresses. + * oscP5 website at http://www.sojamo.de/oscP5 + */ + +import oscP5.*; +import netP5.*; + +OscP5 oscP5; + +void setup() { + size(400,400); + frameRate(25); + /* create a new instance of oscP5 using a multicast socket. */ + oscP5 = new OscP5(this,"239.0.0.1",7777); +} + + +void draw() { + background(0); +} + + +void mousePressed() { + /* create a new OscMessage with an address pattern, in this case /test. */ + OscMessage myOscMessage = new OscMessage("/test"); + + /* add a value (an integer) to the OscMessage */ + myOscMessage.add(100); + + /* send the OscMessage to the multicast group. + * the multicast group netAddress is the default netAddress, therefore + * you dont need to specify a NetAddress to send the osc message. + */ + oscP5.send(myOscMessage); +} + + +/* incoming osc message are forwarded to the oscEvent method. */ +void oscEvent(OscMessage theOscMessage) { + /* print the address pattern and the typetag of the received OscMessage */ + print("### received an osc message."); + print(" addrpattern: "+theOscMessage.addrPattern()); + println(" typetag: "+theOscMessage.typetag()); +} diff --git a/libraries/oscP5/examples/oscP5oscArgument/oscP5oscArgument.pde b/libraries/oscP5/examples/oscP5oscArgument/oscP5oscArgument.pde new file mode 100644 index 0000000..dd67ff0 --- /dev/null +++ b/libraries/oscP5/examples/oscP5oscArgument/oscP5oscArgument.pde @@ -0,0 +1,45 @@ +/** + * oscP5oscArgument by andreas schlegel + * example shows how to parse incoming osc messages "by hand". + * it is recommended to take a look at oscP5plug for an alternative way to parse messages. + * oscP5 website at http://www.sojamo.de/oscP5 + */ + +import oscP5.*; +import netP5.*; + +OscP5 oscP5; +NetAddress myRemoteLocation; + +void setup() { + size(400,400); + frameRate(25); + /* start oscP5, listening for incoming messages at port 12000 */ + oscP5 = new OscP5(this,12000); + myRemoteLocation = new NetAddress("127.0.0.1",12000); + /* send an OSC message to this sketch */ + oscP5.send("/test",new Object[] {new Integer("1"), new Float(2.0),"test string."}, myRemoteLocation); + +} + +void draw() { + background(0); +} + +void oscEvent(OscMessage theOscMessage) { + /* check if theOscMessage has the address pattern we are looking for. */ + if(theOscMessage.checkAddrPattern("/test")==true) { + /* check if the typetag is the right one. */ + if(theOscMessage.checkTypetag("ifs")) { + /* parse theOscMessage and extract the values from the osc message arguments. */ + int firstValue = theOscMessage.get(0).intValue(); // get the first osc argument + float secondValue = theOscMessage.get(1).floatValue(); // get the second osc argument + String thirdValue = theOscMessage.get(2).stringValue(); // get the third osc argument + print("### received an osc message /test with typetag ifs."); + println(" values: "+firstValue+", "+secondValue+", "+thirdValue); + return; + } + } + println("### received an osc message. with address pattern "+ + theOscMessage.addrPattern()+" typetag "+ theOscMessage.typetag()); +} diff --git a/libraries/oscP5/examples/oscP5parsing/oscP5parsing.pde b/libraries/oscP5/examples/oscP5parsing/oscP5parsing.pde new file mode 100644 index 0000000..abb035d --- /dev/null +++ b/libraries/oscP5/examples/oscP5parsing/oscP5parsing.pde @@ -0,0 +1,65 @@ +/** + * oscP5parsing by andreas schlegel + * example shows how to parse incoming osc messages "by hand". + * it is recommended to take a look at oscP5plug for an + * alternative and more convenient way to parse messages. + * oscP5 website at http://www.sojamo.de/oscP5 + */ + +import oscP5.*; +import netP5.*; + +OscP5 oscP5; +NetAddress myRemoteLocation; + +void setup() { + size(400,400); + frameRate(25); + /* start oscP5, listening for incoming messages at port 12000 */ + oscP5 = new OscP5(this,12000); + + /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters, + * an ip address and a port number. myRemoteLocation is used as parameter in + * oscP5.send() when sending osc packets to another computer, device, + * application. usage see below. for testing purposes the listening port + * and the port of the remote location address are the same, hence you will + * send messages back to this sketch. + */ + myRemoteLocation = new NetAddress("127.0.0.1",12000); +} + +void draw() { + background(0); +} + + +void mousePressed() { + /* create a new osc message object */ + OscMessage myMessage = new OscMessage("/test"); + + myMessage.add(123); /* add an int to the osc message */ + myMessage.add(12.34); /* add a float to the osc message */ + myMessage.add("some text"); /* add a string to the osc message */ + + /* send the message */ + oscP5.send(myMessage, myRemoteLocation); +} + + +void oscEvent(OscMessage theOscMessage) { + /* check if theOscMessage has the address pattern we are looking for. */ + + if(theOscMessage.checkAddrPattern("/test")==true) { + /* check if the typetag is the right one. */ + if(theOscMessage.checkTypetag("ifs")) { + /* parse theOscMessage and extract the values from the osc message arguments. */ + int firstValue = theOscMessage.get(0).intValue(); + float secondValue = theOscMessage.get(1).floatValue(); + String thirdValue = theOscMessage.get(2).stringValue(); + print("### received an osc message /test with typetag ifs."); + println(" values: "+firstValue+", "+secondValue+", "+thirdValue); + return; + } + } + println("### received an osc message. with address pattern "+theOscMessage.addrPattern()); +} diff --git a/libraries/oscP5/examples/oscP5plug/oscP5plug.pde b/libraries/oscP5/examples/oscP5plug/oscP5plug.pde new file mode 100644 index 0000000..5b72973 --- /dev/null +++ b/libraries/oscP5/examples/oscP5plug/oscP5plug.pde @@ -0,0 +1,82 @@ +/** + * oscP5plug by andreas schlegel + * example shows how to use the plug service with oscP5. + * the concept of the plug service is, that you can + * register methods in your sketch to which incoming + * osc messages will be forwareded automatically without + * having to parse them in the oscEvent method. + * that a look at the example below to get an understanding + * of how plug works. + * oscP5 website at http://www.sojamo.de/oscP5 + */ + +import oscP5.*; +import netP5.*; + +OscP5 oscP5; +NetAddress myRemoteLocation; + +void setup() { + size(400,400); + frameRate(25); + /* start oscP5, listening for incoming messages at port 12000 */ + oscP5 = new OscP5(this,12000); + + /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters, + * an ip address and a port number. myRemoteLocation is used as parameter in + * oscP5.send() when sending osc packets to another computer, device, + * application. usage see below. for testing purposes the listening port + * and the port of the remote location address are the same, hence you will + * send messages back to this sketch. + */ + myRemoteLocation = new NetAddress("127.0.0.1",12000); + + /* osc plug service + * osc messages with a specific address pattern can be automatically + * forwarded to a specific method of an object. in this example + * a message with address pattern /test will be forwarded to a method + * test(). below the method test takes 2 arguments - 2 ints. therefore each + * message with address pattern /test and typetag ii will be forwarded to + * the method test(int theA, int theB) + */ + oscP5.plug(this,"test","/test"); +} + + +public void test(int theA, int theB) { + println("### plug event method. received a message /test."); + println(" 2 ints received: "+theA+", "+theB); +} + + +void draw() { + background(0); +} + + +void mousePressed() { + /* createan osc message with address pattern /test */ + OscMessage myMessage = new OscMessage("/test"); + + myMessage.add(123); /* add an int to the osc message */ + myMessage.add(456); /* add a second int to the osc message */ + + /* send the message */ + oscP5.send(myMessage, myRemoteLocation); +} + + +/* incoming osc message are forwarded to the oscEvent method. */ +void oscEvent(OscMessage theOscMessage) { + /* with theOscMessage.isPlugged() you check if the osc message has already been + * forwarded to a plugged method. if theOscMessage.isPlugged()==true, it has already + * been forwared to another method in your sketch. theOscMessage.isPlugged() can + * be used for double posting but is not required. + */ + if(theOscMessage.isPlugged()==false) { + /* print the address pattern and the typetag of the received OscMessage */ + println("### received an osc message."); + println("### addrpattern\t"+theOscMessage.addrPattern()); + println("### typetag\t"+theOscMessage.typetag()); + } +} diff --git a/libraries/oscP5/examples/oscP5properties/oscP5properties.pde b/libraries/oscP5/examples/oscP5properties/oscP5properties.pde new file mode 100644 index 0000000..a0756fe --- /dev/null +++ b/libraries/oscP5/examples/oscP5properties/oscP5properties.pde @@ -0,0 +1,72 @@ +/** + * oscP5properities by andreas schlegel + * example shows how to use osc properties. + * if you need more specific settings for your osc session, + * osc properties serves your needs. + * oscP5 website at http://www.sojamo.de/oscP5 + */ +import oscP5.*; +import netP5.*; + +OscP5 oscP5; + +void setup() { + size(400,400); + frameRate(25); + + /* create a new osc properties object */ + OscProperties properties = new OscProperties(); + + /* set a default NetAddress. sending osc messages with no NetAddress parameter + * in oscP5.send() will be sent to the default NetAddress. + */ + properties.setRemoteAddress("127.0.0.1",12000); + + /* the port number you are listening for incoming osc packets. */ + properties.setListeningPort(12000); + + + /* Send Receive Same Port is an option where the sending and receiving port are the same. + * this is sometimes necessary for example when sending osc packets to supercolider server. + * while both port numbers are the same, the receiver can simply send an osc packet back to + * the host and port the message came from. + */ + properties.setSRSP(OscProperties.ON); + + /* set the datagram byte buffer size. this can be useful when you send/receive + * huge amounts of data, but keep in mind, that UDP is limited to 64k + */ + properties.setDatagramSize(1024); + + /* initialize oscP5 with our osc properties */ + oscP5 = new OscP5(this,properties); + + /* print your osc properties */ + println(properties.toString()); +} + + + +void mousePressed() { + /* create a new osc message with address pattern /test */ + OscMessage myMessage = new OscMessage("/test"); + myMessage.add(200); + + /* send the osc message to the default netAddress, set in the OscProperties above.*/ + oscP5.send(myMessage); +} + + +void draw() { + background(0); +} + + + +/* incoming osc message are forwarded to the oscEvent method. */ +void oscEvent(OscMessage theOscMessage) { + /* print the address pattern and the typetag of the received OscMessage */ + print("### received an osc message."); + print(" addrpattern: "+theOscMessage.addrPattern()); + println(" typetag: "+theOscMessage.typetag()); +} diff --git a/libraries/oscP5/examples/oscP5sendReceive/oscP5sendReceive.pde b/libraries/oscP5/examples/oscP5sendReceive/oscP5sendReceive.pde new file mode 100644 index 0000000..0159a63 --- /dev/null +++ b/libraries/oscP5/examples/oscP5sendReceive/oscP5sendReceive.pde @@ -0,0 +1,51 @@ +/** + * oscP5sendreceive by andreas schlegel + * example shows how to send and receive osc messages. + * oscP5 website at http://www.sojamo.de/oscP5 + */ + +import oscP5.*; +import netP5.*; + +OscP5 oscP5; +NetAddress myRemoteLocation; + +void setup() { + size(400,400); + frameRate(25); + /* start oscP5, listening for incoming messages at port 12000 */ + oscP5 = new OscP5(this,12000); + + /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters, + * an ip address and a port number. myRemoteLocation is used as parameter in + * oscP5.send() when sending osc packets to another computer, device, + * application. usage see below. for testing purposes the listening port + * and the port of the remote location address are the same, hence you will + * send messages back to this sketch. + */ + myRemoteLocation = new NetAddress("127.0.0.1",12000); +} + + +void draw() { + background(0); +} + +void mousePressed() { + /* in the following different ways of creating osc messages are shown by example */ + OscMessage myMessage = new OscMessage("/test"); + + myMessage.add(123); /* add an int to the osc message */ + + /* send the message */ + oscP5.send(myMessage, myRemoteLocation); +} + + +/* incoming osc message are forwarded to the oscEvent method. */ +void oscEvent(OscMessage theOscMessage) { + /* print the address pattern and the typetag of the received OscMessage */ + print("### received an osc message."); + print(" addrpattern: "+theOscMessage.addrPattern()); + println(" typetag: "+theOscMessage.typetag()); +} diff --git a/libraries/oscP5/examples/oscP5tcp/oscP5tcp.pde b/libraries/oscP5/examples/oscP5tcp/oscP5tcp.pde new file mode 100644 index 0000000..90ee312 --- /dev/null +++ b/libraries/oscP5/examples/oscP5tcp/oscP5tcp.pde @@ -0,0 +1,59 @@ +/** + * oscP5tcp by andreas schlegel + * example shows how to use the TCP protocol with oscP5. + * what is TCP? http://en.wikipedia.org/wiki/Transmission_Control_Protocol + * in this example both, a server and a client are used. typically + * this doesnt make sense as you usually wouldnt communicate with yourself + * over a network. therefore this example is only to make it easier to + * explain the concept of using tcp with oscP5. + * oscP5 website at http://www.sojamo.de/oscP5 + */ + +import oscP5.*; +import netP5.*; + + +OscP5 oscP5tcpServer; + +OscP5 oscP5tcpClient; + +NetAddress myServerAddress; + +void setup() { + /* create an oscP5 instance using TCP listening @ port 11000 */ + oscP5tcpServer = new OscP5(this, 11000, OscP5.TCP); + + /* create an oscP5 instance using TCP. + * the remote address is 127.0.0.1 @ port 11000 = the server from above + */ + oscP5tcpClient = new OscP5(this, "127.0.0.1", 11000, OscP5.TCP); +} + + +void draw() { + background(0); +} + + +void mousePressed() { + /* the tcp client sends a message to the server it is connected to.*/ + oscP5tcpClient.send("/test", new Object[] {new Integer(1)}); +} + + +void keyPressed() { + /* check how many clients are connected to the server. */ + println(oscP5tcpServer.tcpServer().getClients().length); +} + +void oscEvent(OscMessage theMessage) { + /* in this example, both the server and the client share this oscEvent method */ + System.out.println("### got a message " + theMessage); + if(theMessage.checkAddrPattern("/test")) { + /* message was send from the tcp client */ + OscMessage m = new OscMessage("/response"); + m.add("server response: got it"); + /* server responds to the client's message */ + oscP5tcpServer.send(m,theMessage.tcpConnection()); + } +} diff --git a/libraries/oscP5/library.properties b/libraries/oscP5/library.properties new file mode 100644 index 0000000..5206422 --- /dev/null +++ b/libraries/oscP5/library.properties @@ -0,0 +1,44 @@ +# UTF-8 supported. + +# The name of your library as you want it formatted +name = oscP5 + +# List of authors. Links can be provided using the syntax [author name](url) +authorList = [Andreas Schlegel](http://www.sojamo.de/) + +# A website for your library +url = http://www.sojamo.de/libraries/oscp5 + +# The category of your library, must be one (or many) of the following: +# "3D" "Animation" "Compilations" "Data" +# "Fabrication" "Geometry" "GUI" "Hardware" +# "I/O" "Language" "Math" "Simulation" +# "Sound" "Utilities" "Typography" "Video & Vision" +# +# If a value other than those listed is used, your library will listed as "Other." +category = Data + +# A short sentence (fragment) to summarize the library's function. This will be +# shown from inside the PDE when the library is being installed. Avoid repeating +# the name of your library here. Also, avoid saying anything redundant like +# mentioning that its a library. +sentence = An Open Sound Control (OSC) implementation. + +# Additional information suitable for the Processing website. The value of +# 'sentence' always will be prepended, so you should start by writing the +# second sentence here. If your library only works on certain operating systems, +# mention it here. +paragraph = The UDP, TCP, Multicast protocols are supported and can be used for client/server communication independently from OSC as well. + +# Links in the 'sentence' and 'paragraph' attributes can be inserted using the +# same syntax as for authors. That is, [here is a link to Processing](http://processing.org/) + + +# A version number that increments once with each release. This +# is used to compare different versions of the same library, and +# check if an update is available. You should think of it as a +# counter, counting the total number of releases you've had. +version = 99 # This must be parsable as an int + +# The version as the user will see it. If blank, the version attribute will be used here +prettyVersion = 0.9.9 # This is treated as a String \ No newline at end of file diff --git a/libraries/oscP5/library/oscP5.jar b/libraries/oscP5/library/oscP5.jar new file mode 100644 index 0000000..28fe7bd Binary files /dev/null and b/libraries/oscP5/library/oscP5.jar differ diff --git a/libraries/oscP5/reference/allclasses-frame.html b/libraries/oscP5/reference/allclasses-frame.html new file mode 100644 index 0000000..092fd03 --- /dev/null +++ b/libraries/oscP5/reference/allclasses-frame.html @@ -0,0 +1,99 @@ + + + + + + +All Classes (Javadocs: oscP5) + + + + + + + + + + + +All Classes +
+ + + + + +
AbstractMulticast +
+AbstractTcpClient +
+AbstractTcpServer +
+AbstractUdpClient +
+AbstractUdpServer +
+Bytes +
+Logger +
+Multicast +
+NetAddress +
+NetAddressList +
+NetInfo +
+NetListener +
+NetMessage +
+NetP5 +
+NetStatus +
+OscArgument +
+OscBundle +
+OscEventListener +
+OscIn +
+OscMessage +
+OscNetManager +
+OscP5 +
+OscPacket +
+OscPatcher +
+OscPlug +
+OscProperties +
+OscStatus +
+StringUtils +
+TcpClient +
+TcpPacket +
+TcpPacketListener +
+TcpServer +
+UdpClient +
+UdpPacketListener +
+UdpServer +
+
+ + + diff --git a/libraries/oscP5/reference/allclasses-noframe.html b/libraries/oscP5/reference/allclasses-noframe.html new file mode 100644 index 0000000..c2a3e53 --- /dev/null +++ b/libraries/oscP5/reference/allclasses-noframe.html @@ -0,0 +1,99 @@ + + + + + + +All Classes (Javadocs: oscP5) + + + + + + + + + + + +All Classes +
+ + + + + +
AbstractMulticast +
+AbstractTcpClient +
+AbstractTcpServer +
+AbstractUdpClient +
+AbstractUdpServer +
+Bytes +
+Logger +
+Multicast +
+NetAddress +
+NetAddressList +
+NetInfo +
+NetListener +
+NetMessage +
+NetP5 +
+NetStatus +
+OscArgument +
+OscBundle +
+OscEventListener +
+OscIn +
+OscMessage +
+OscNetManager +
+OscP5 +
+OscPacket +
+OscPatcher +
+OscPlug +
+OscProperties +
+OscStatus +
+StringUtils +
+TcpClient +
+TcpPacket +
+TcpPacketListener +
+TcpServer +
+UdpClient +
+UdpPacketListener +
+UdpServer +
+
+ + + diff --git a/libraries/oscP5/reference/constant-values.html b/libraries/oscP5/reference/constant-values.html new file mode 100644 index 0000000..e505a0b --- /dev/null +++ b/libraries/oscP5/reference/constant-values.html @@ -0,0 +1,446 @@ + + + + + + +Constant Field Values (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Constant Field Values

+
+
+Contents + + + + + + +
+netP5.*
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
netP5.AbstractTcpClient
+public static final intMODE_NEWLINE2
+public static final intMODE_READLINE0
+public static final intMODE_STREAM3
+public static final intMODE_TERMINATED1
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
netP5.AbstractTcpServer
+public static final intMODE_NEWLINE2
+public static final intMODE_READLINE0
+public static final intMODE_STREAM3
+public static final intMODE_TERMINATED1
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
netP5.Logger
+public static final intALL5
+public static final intDEBUG4
+public static final intERROR0
+public static final intINFO3
+public static final intOFF1
+public static final intON0
+public static final intPROCESS2
+public static final intWARNING1
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
netP5.NetP5
+public static final booleanDEBUGtrue
+public static final intMULTICAST1
+public static final intTCP2
+public static final intUDP0
+public static final StringVERSION"0.9.9"
+ +

+ +

+ + + + + +
+oscP5.*
+ +

+ + + + + + + + + + + + +
oscP5.OscNetManager
+public static final intNONE0
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
oscP5.OscP5
+public static final intMULTICAST1
+public static final booleanOFFfalse
+public static final booleanONtrue
+public static final intTCP2
+public static final intUDP0
+public static final StringVERSION"0.9.9"
+ +

+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
oscP5.OscProperties
+public static final intMULTICAST1
+public static final booleanOFFfalse
+public static final booleanONtrue
+public static final intTCP2
+public static final intUDP0
+ +

+ +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/deprecated-list.html b/libraries/oscP5/reference/deprecated-list.html new file mode 100644 index 0000000..1493777 --- /dev/null +++ b/libraries/oscP5/reference/deprecated-list.html @@ -0,0 +1,229 @@ + + + + + + +Deprecated List (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Deprecated API

+
+
+Contents + + + + + + + + + +
+Deprecated Classes
oscP5.OscIn +
+           
+  +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Deprecated Methods
oscP5.OscP5.disconnectFromTEMP() +
+            
oscP5.OscP5.flush(byte[], String, int) +
+            
oscP5.OscP5.flush(OscMessage, String, int) +
+            
netP5.AbstractTcpClient.netaddress() +
+            
oscP5.OscPacket.netaddress() +
+            
oscP5.OscP5.newBundle() +
+            
oscP5.OscP5.newMsg(String) +
+            
oscP5.OscP5.send(OscPacket, String, int) +
+            
+  +

+ + + + + + + + + + + +
+Deprecated Constructors
oscP5.OscP5(Object, String, int) +
+            
oscP5.OscP5(Object, String, int, int, String) +
+            
+  +

+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/help-doc.html b/libraries/oscP5/reference/help-doc.html new file mode 100644 index 0000000..e23a628 --- /dev/null +++ b/libraries/oscP5/reference/help-doc.html @@ -0,0 +1,217 @@ + + + + + + +API Help (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+How This API Document Is Organized

+
+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

+Overview

+
+ +

+The Overview page is the front page of this API document and provides a list of all packages with a summary for each. This page can also contain an overall description of the set of packages.

+

+Package

+
+ +

+Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

+
+

+Class/Interface

+
+ +

+Each class, interface, nested class and nested interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+ +

+Annotation Type

+
+ +

+Each annotation type has its own separate page with the following sections:

+
+ +

+Enum

+
+ +

+Each enum has its own separate page with the following sections:

+
+

+Tree (Class Hierarchy)

+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object. +
+

+Deprecated API

+
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+

+Index

+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+

+Prev/Next

+These links take you to the next or previous class, interface, package, or related page.

+Frames/No Frames

+These links show and hide the HTML frames. All pages are available with or without frames. +

+

+Serialized Form

+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. +

+

+Constant Field Values

+The Constant Field Values page lists the static final fields and their values. +

+ + +This help file applies to API documentation generated using the standard doclet. + +
+


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/index-all.html b/libraries/oscP5/reference/index-all.html new file mode 100644 index 0000000..17407d9 --- /dev/null +++ b/libraries/oscP5/reference/index-all.html @@ -0,0 +1,1692 @@ + + + + + + +Index (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +A B C D E F G H I L M N O P R S T U V W
+

+A

+
+
AbstractMulticast - Class in netP5
 
AbstractMulticast(UdpPacketListener, String, int, int) - +Constructor for class netP5.AbstractMulticast +
  +
AbstractMulticast(UdpPacketListener, String, int) - +Constructor for class netP5.AbstractMulticast +
  +
AbstractTcpClient - Class in netP5
 
AbstractTcpClient(TcpPacketListener, String, int) - +Constructor for class netP5.AbstractTcpClient +
  +
AbstractTcpClient(String, int) - +Constructor for class netP5.AbstractTcpClient +
  +
AbstractTcpClient(TcpPacketListener, String, int, int) - +Constructor for class netP5.AbstractTcpClient +
  +
AbstractTcpClient(String, int, int) - +Constructor for class netP5.AbstractTcpClient +
  +
AbstractTcpClient(AbstractTcpServer, Socket, TcpPacketListener, int, int) - +Constructor for class netP5.AbstractTcpClient +
  +
AbstractTcpServer - Class in netP5
 
AbstractTcpServer(int, int) - +Constructor for class netP5.AbstractTcpServer +
  +
AbstractTcpServer(TcpPacketListener, int, int) - +Constructor for class netP5.AbstractTcpServer +
  +
AbstractUdpClient - Class in netP5
 
AbstractUdpClient() - +Constructor for class netP5.AbstractUdpClient +
  +
AbstractUdpClient(String, int) - +Constructor for class netP5.AbstractUdpClient +
  +
AbstractUdpServer - Class in netP5
 
AbstractUdpServer(UdpPacketListener, int, int) - +Constructor for class netP5.AbstractUdpServer +
create a new UdpServer +
add(NetAddress) - +Method in class netP5.NetAddressList +
  +
add(String, int) - +Method in class netP5.NetAddressList +
  +
add(OscMessage) - +Method in class oscP5.OscBundle +
add an osc message to the osc bundle. +
add() - +Method in class oscP5.OscMessage +
add values to an osc message. +
add(int) - +Method in class oscP5.OscMessage +
  +
add(String) - +Method in class oscP5.OscMessage +
  +
add(float) - +Method in class oscP5.OscMessage +
  +
add(double) - +Method in class oscP5.OscMessage +
  +
add(boolean) - +Method in class oscP5.OscMessage +
  +
add(Boolean) - +Method in class oscP5.OscMessage +
  +
add(Integer) - +Method in class oscP5.OscMessage +
  +
add(Float) - +Method in class oscP5.OscMessage +
  +
add(Double) - +Method in class oscP5.OscMessage +
  +
add(Character) - +Method in class oscP5.OscMessage +
  +
add(char) - +Method in class oscP5.OscMessage +
  +
add(int, int, int, int) - +Method in class oscP5.OscMessage +
  +
add(int[]) - +Method in class oscP5.OscMessage +
  +
add(char[]) - +Method in class oscP5.OscMessage +
  +
add(float[]) - +Method in class oscP5.OscMessage +
  +
add(String[]) - +Method in class oscP5.OscMessage +
  +
add(byte[]) - +Method in class oscP5.OscMessage +
  +
add(Object[]) - +Method in class oscP5.OscMessage +
  +
addArguments(Object[]) - +Method in class oscP5.OscMessage +
add a list of arguments to an exisiting set of arguments. +
addListener(NetListener) - +Method in class netP5.Multicast +
  +
addListener(NetListener) - +Method in class netP5.TcpServer +
  +
addListener(NetListener) - +Method in class netP5.UdpServer +
add a listener to the udp server. +
addListener(OscEventListener) - +Method in class oscP5.OscP5 +
  +
address() - +Method in class netP5.NetAddress +
returns the remote ip address as string +
address() - +Method in class netP5.NetMessage +
  +
address() - +Method in class oscP5.OscPacket +
  +
addrInt() - +Method in class oscP5.OscMessage +
returns the address pattern of the osc message as int. +
addrPattern() - +Method in class oscP5.OscMessage +
  +
addTcpListener(TcpPacketListener) - +Method in class oscP5.OscNetManager +
  +
addUdpListener(UdpPacketListener) - +Method in class oscP5.OscNetManager +
  +
ALL - +Static variable in class netP5.Logger +
  +
append(byte[], byte[]) - +Static method in class netP5.Bytes +
  +
append(byte[], byte[], byte[]) - +Static method in class netP5.Bytes +
  +
areEqual(byte[], byte[]) - +Static method in class netP5.Bytes +
  +
arguments() - +Method in class oscP5.OscMessage +
  +
arrayToString(String[]) - +Static method in class netP5.StringUtils +
  +
arrayToString(String[], int, int) - +Static method in class netP5.StringUtils +
  +
+
+

+B

+
+
ban(String) - +Method in class netP5.AbstractTcpServer +
ban an IP address from the server. +
blobValue() - +Method in class oscP5.OscArgument +
get the byte array (blob) of the osc argument. +
booleanValue() - +Method in class oscP5.OscArgument +
get the boolean value of the osc argument. +
Bytes - Class in netP5
 
Bytes() - +Constructor for class netP5.Bytes +
  +
bytesValue() - +Method in class oscP5.OscArgument +
get the byte array of the osc argument. +
+
+

+C

+
+
centerJustify(String, int) - +Static method in class netP5.StringUtils +
Creates a string of the given width with the given string left justified + (padded by an appropriate number of spaces in front and after it). +
charValue() - +Method in class oscP5.OscArgument +
get the char value of the osc argument. +
checkAddrPattern(String) - +Method in class oscP5.OscMessage +
check if an address pattern equals a specific address pattern + you are looking for. +
checkMethod(OscMessage, boolean) - +Method in class oscP5.OscPlug +
  +
checkType(String) - +Method in class oscP5.OscPlug +
  +
checkTypetag(String) - +Method in class oscP5.OscMessage +
  +
clear() - +Method in class oscP5.OscBundle +
clear and reset the osc bundle for reusing. +
clear() - +Method in class oscP5.OscMessage +
clear and reset an OscMessage for reuse. +
clearArguments() - +Method in class oscP5.OscMessage +
clears the arguments in a message, + but keeps the address the address pattern. +
CLIENT_CLOSED - +Static variable in class netP5.NetStatus +
  +
CLIENT_CLOSED - +Static variable in class oscP5.OscStatus +
  +
close() - +Method in class netP5.AbstractMulticast +
  +
connect(NetAddress, String, String[]) - +Method in class oscP5.OscP5 +
  +
CONNECTION_CLOSED - +Static variable in class netP5.NetStatus +
  +
CONNECTION_CLOSED - +Static variable in class oscP5.OscStatus +
  +
CONNECTION_FAILED - +Static variable in class netP5.NetStatus +
  +
CONNECTION_FAILED - +Static variable in class oscP5.OscStatus +
  +
CONNECTION_REFUSED - +Static variable in class netP5.NetStatus +
  +
CONNECTION_REFUSED - +Static variable in class oscP5.OscStatus +
  +
CONNECTION_TERMINATED - +Static variable in class netP5.NetStatus +
  +
CONNECTION_TERMINATED - +Static variable in class oscP5.OscStatus +
  +
contains(NetAddress) - +Method in class netP5.NetAddressList +
  +
contains(String, int) - +Method in class netP5.NetAddressList +
  +
copy(byte[], int) - +Static method in class netP5.Bytes +
  +
copy(byte[], int, int) - +Static method in class netP5.Bytes +
  +
+
+

+D

+
+
datagramSize() - +Method in class oscP5.OscProperties +
returns the current size of the datagram bytebuffer. +
DEBUG - +Static variable in class netP5.Logger +
  +
DEBUG - +Static variable in interface netP5.NetP5 +
  +
DEFAULT - +Static variable in class netP5.NetStatus +
  +
DEFAULT - +Static variable in class oscP5.OscStatus +
  +
disconnect(NetAddress) - +Method in class oscP5.OscP5 +
  +
disconnectFromTEMP() - +Method in class oscP5.OscP5 +
Deprecated.   +
dispose() - +Method in class netP5.AbstractMulticast +
dispose the multicastSocket. +
dispose() - +Method in class netP5.AbstractTcpClient +
stop and dispose a tcp client. +
dispose() - +Method in class netP5.AbstractTcpServer +
kill the server. +
dispose() - +Method in class netP5.AbstractUdpServer +
stop the UDP server, clean up and delete its reference. +
dispose() - +Method in class oscP5.OscP5 +
  +
doubleValue() - +Method in class oscP5.OscArgument +
get the double value of the osc argument. +
duplicate(String, int) - +Static method in class netP5.StringUtils +
Returns a String with the source String copied the specified number of + times. +
+
+

+E

+
+
equals(NetAddress) - +Method in class netP5.AbstractTcpClient +
  +
equals(TcpClient) - +Method in class netP5.AbstractTcpClient +
  +
ERROR - +Static variable in class netP5.Logger +
  +
ERROR - +Static variable in class netP5.NetStatus +
  +
ERROR - +Static variable in class oscP5.OscStatus +
  +
eventMethod() - +Method in class oscP5.OscProperties +
  +
explode(String[], int[]) - +Static method in class netP5.StringUtils +
Splits every String in an array at the specified lengths. +
explode(String, int[]) - +Static method in class netP5.StringUtils +
Splits a string at the specified lengths and returns an array of Strings. +
explode(String) - +Static method in class netP5.StringUtils +
Splits a string into an array with a space as delimiter. +
explode(String, String) - +Static method in class netP5.StringUtils +
Splits a string into an array with the specified delimiter. +
+
+

+F

+
+
flags - +Static variable in class netP5.Logger +
  +
floatValue() - +Method in class oscP5.OscArgument +
get the float value of the osc argument. +
flush(OscMessage, NetAddress) - +Static method in class oscP5.OscP5 +
a static method to send an OscMessage straight out of the box without having to instantiate + oscP5. +
flush(OscPacket, NetAddress) - +Static method in class oscP5.OscP5 +
  +
flush(String, Object[], NetAddress) - +Static method in class oscP5.OscP5 +
  +
flush(byte[], NetAddress) - +Static method in class oscP5.OscP5 +
  +
flush(byte[], String, int) - +Static method in class oscP5.OscP5 +
Deprecated.   +
flush(OscMessage, String, int) - +Static method in class oscP5.OscP5 +
Deprecated.   +
+
+

+G

+
+
get(String, int) - +Method in class netP5.NetAddressList +
  +
get(int) - +Method in class netP5.NetAddressList +
  +
get(int) - +Method in class oscP5.OscMessage +
get a value at a specific position in the osc message. +
getAddrPatternAsBytes() - +Method in class oscP5.OscMessage +
  +
getAsString(Object[]) - +Static method in class netP5.Bytes +
converts an object array into a String that is formated like a list +
getAsString(byte[]) - +Static method in class netP5.Bytes +
  +
getBlob(int) - +Method in class oscP5.OscIn +
Deprecated.   +
getBoolean(int) - +Method in class oscP5.OscIn +
Deprecated.   +
getBytes() - +Method in class oscP5.OscBundle +
  +
getBytes() - +Method in class oscP5.OscMessage +
  +
getBytes() - +Method in class oscP5.OscPacket +
  +
getChar(int) - +Method in class oscP5.OscIn +
Deprecated.   +
getClient(int) - +Method in class netP5.AbstractTcpServer +
get a client at a specific position the client list. +
getClients() - +Method in class netP5.AbstractTcpServer +
get a list of all connected clients. +
getData() - +Method in class netP5.NetMessage +
get the data of the message as bytes. +
getData() - +Method in class netP5.TcpPacket +
  +
getDatagramPacket() - +Method in class netP5.NetMessage +
  +
getDataList() - +Method in class oscP5.OscIn +
Deprecated. this is only for christian's and jens' table communication with vvvv. +
getFloat(String) - +Static method in class netP5.StringUtils +
  +
getFloat(int) - +Method in class oscP5.OscIn +
Deprecated.   +
getHostAddress() - +Static method in class netP5.NetInfo +
  +
getInt(String) - +Static method in class netP5.StringUtils +
  +
getInt(int) - +Method in class oscP5.OscIn +
Deprecated.   +
getListener(int) - +Method in class netP5.Multicast +
  +
getListener(int) - +Method in class netP5.TcpServer +
  +
getListener(int) - +Method in class netP5.UdpServer +
  +
getListeners() - +Method in class netP5.Multicast +
  +
getListeners() - +Method in class netP5.TcpServer +
  +
getListeners() - +Method in class netP5.UdpServer +
  +
getMessage(int) - +Method in class oscP5.OscBundle +
request an osc message inside the osc bundle array, +
getMethod() - +Method in class oscP5.OscPlug +
  +
getMidi(int) - +Method in class oscP5.OscIn +
Deprecated.   +
getMidiBytes(int) - +Method in class oscP5.OscIn +
Deprecated.   +
getObject() - +Method in class oscP5.OscPlug +
  +
getStackTrace(Throwable) - +Static method in class netP5.StringUtils +
Prints the stacktrace to a buffer and returns the buffer as a String. +
getString() - +Method in class netP5.AbstractTcpClient +
  +
getString() - +Method in class netP5.NetMessage +
get the data the message as string. +
getString() - +Method in class netP5.TcpPacket +
  +
getString(int) - +Method in class oscP5.OscIn +
Deprecated.   +
getStringBuffer() - +Method in class netP5.AbstractTcpClient +
  +
getStringBuffer() - +Method in class netP5.TcpPacket +
  +
getTcpConnection() - +Method in class netP5.TcpPacket +
  +
getTcpPacket() - +Method in class netP5.NetMessage +
  +
getTime() - +Static method in class netP5.Logger +
  +
getTypetagAsBytes() - +Method in class oscP5.OscMessage +
  +
+
+

+H

+
+
handleInput() - +Method in class netP5.AbstractTcpClient +
  +
handleInput(TcpPacket, int) - +Method in class netP5.AbstractTcpServer +
  +
handleInput() - +Method in class netP5.TcpClient +
  +
handleInput(TcpPacket, int) - +Method in class netP5.TcpServer +
  +
handleStatus(int) - +Method in class netP5.AbstractTcpClient +
  +
handleStatus(int) - +Method in class netP5.TcpClient +
  +
+
+

+I

+
+
id() - +Method in class netP5.NetStatus +
  +
id() - +Method in class oscP5.OscStatus +
  +
implode(Object[], String) - +Static method in class netP5.StringUtils +
Combines an array to a string, using the specified delimiter. +
implode(Object[]) - +Static method in class netP5.StringUtils +
Combines an array to a string, using a comma and a space as delimiter. +
inetaddress() - +Method in class netP5.NetAddress +
  +
inetAddress() - +Method in class netP5.NetMessage +
  +
INFO - +Static variable in class netP5.Logger +
  +
intValue() - +Method in class oscP5.OscArgument +
get the int value of the osc argument. +
ip() - +Method in class oscP5.OscP5 +
  +
isBroadcast() - +Method in class oscP5.OscP5 +
  +
isEmpty(String) - +Static method in class netP5.StringUtils +
Checks if a String is empty or null. +
isPlugged() - +Method in class oscP5.OscMessage +
  +
isvalid() - +Method in class netP5.NetAddress +
check if the netAddress is valid. +
+
+

+L

+
+
lan() - +Static method in class netP5.NetInfo +
  +
left(String, String) - +Static method in class netP5.StringUtils +
Returns the substring to the left of the specified substring in the + specified String, starting from the left. +
leftBack(String, String) - +Static method in class netP5.StringUtils +
Returns the substring to the left of the specified substring in the + specified String, starting from the right. +
leftJustify(String, int) - +Static method in class netP5.StringUtils +
Creates a string of the given width with the given string left justified + (followed by an appropriate number of spaces). +
list() - +Method in class netP5.NetAddressList +
  +
listener() - +Method in class netP5.AbstractTcpClient +
  +
listeners() - +Method in class oscP5.OscP5 +
  +
listeners() - +Method in class oscP5.OscProperties +
  +
listeningPort() - +Method in class oscP5.OscProperties +
returns the port number currently used to receive osc packets. +
Logger - Class in netP5
 
Logger() - +Constructor for class netP5.Logger +
  +
longValue() - +Method in class oscP5.OscArgument +
get the long value of the osc argument. +
loopback() - +Method in class netP5.AbstractMulticast +
get the current loopback mode. +
+
+

+M

+
+
main(String[]) - +Static method in class netP5.NetInfo +
  +
makeBlob(byte[]) - +Static method in class oscP5.OscMessage +
  +
merge(byte[], byte[], int, int, int) - +Static method in class netP5.Bytes +
  +
merge(byte[], byte[], int) - +Static method in class netP5.Bytes +
  +
merge(byte[], byte[]) - +Static method in class netP5.Bytes +
  +
merge(byte[], byte[], int, int) - +Static method in class netP5.Bytes +
  +
method - +Variable in class oscP5.OscPlug +
  +
middle(String, String, String) - +Static method in class netP5.StringUtils +
Returns the substring between two substrings. +
middle(String, int, int) - +Static method in class netP5.StringUtils +
Returns a substring of a String, starting from specified index and with + specified length. +
midiValue() - +Method in class oscP5.OscArgument +
  +
mode() - +Method in class netP5.AbstractTcpClient +
get the mode of the terminator. +
MODE_NEWLINE - +Static variable in class netP5.AbstractTcpClient +
terminator is newline. +
MODE_NEWLINE - +Static variable in class netP5.AbstractTcpServer +
  +
MODE_READLINE - +Static variable in class netP5.AbstractTcpClient +
terminator is readline. +
MODE_READLINE - +Static variable in class netP5.AbstractTcpServer +
  +
MODE_STREAM - +Static variable in class netP5.AbstractTcpClient +
no terminator required, packets are sent via + a tcp stream. +
MODE_STREAM - +Static variable in class netP5.AbstractTcpServer +
  +
MODE_TERMINATED - +Static variable in class netP5.AbstractTcpClient +
terminator is terminated, by default this is character '\0' + and can be set with setTerminator +
MODE_TERMINATED - +Static variable in class netP5.AbstractTcpServer +
  +
Multicast - Class in netP5
Multicast is a method of forwarding IP datagrams to a group of interested receivers.
Multicast(Object, String, int, int) - +Constructor for class netP5.Multicast +
create a new instance of Multicast. +
Multicast(Object, String, int) - +Constructor for class netP5.Multicast +
  +
Multicast(UdpPacketListener, String, int, int) - +Constructor for class netP5.Multicast +
  +
Multicast(UdpPacketListener, String, int) - +Constructor for class netP5.Multicast +
  +
MULTICAST - +Static variable in interface netP5.NetP5 +
  +
MULTICAST - +Static variable in class oscP5.OscP5 +
a static variable used when creating an oscP5 instance with a sepcified network protocol. +
MULTICAST - +Static variable in class oscP5.OscProperties +
  +
+
+

+N

+
+
name - +Variable in class netP5.NetAddress +
  +
name() - +Method in class netP5.TcpClient +
  +
netAddress() - +Method in class netP5.AbstractTcpClient +
  +
netaddress() - +Method in class netP5.AbstractTcpClient +
Deprecated.   +
NetAddress - Class in netP5
NetAddress is an Object that contains an inetaddress + of an remote internet address, consisting of an + ip address and a port number.
NetAddress(String, int) - +Constructor for class netP5.NetAddress +
  +
NetAddress(NetAddress) - +Constructor for class netP5.NetAddress +
  +
NetAddress(InetAddress, int) - +Constructor for class netP5.NetAddress +
  +
netAddress() - +Method in class oscP5.OscPacket +
  +
netaddress() - +Method in class oscP5.OscPacket +
Deprecated.   +
NetAddressList - Class in netP5
NetAddressList is an arraylist of netaddresses.
NetAddressList() - +Constructor for class netP5.NetAddressList +
  +
netEvent(NetMessage) - +Method in interface netP5.NetListener +
  +
NetInfo - Class in netP5
some description
NetInfo() - +Constructor for class netP5.NetInfo +
  +
netInfo() - +Method in class oscP5.OscP5 +
netinfo() returns an instance of a NetInfo Object from which you can get LAN and WAN + information. +
NetListener - Interface in netP5
 
NetMessage - Class in netP5
 
netP5 - package netP5
 
NetP5 - Interface in netP5
 
netStatus(NetStatus) - +Method in interface netP5.NetListener +
  +
NetStatus - Class in netP5
 
NetStatus(int) - +Constructor for class netP5.NetStatus +
  +
networkProtocol() - +Method in class oscP5.OscProperties +
returns the network protocol being used to transmit osc packets. +
newBundle() - +Method in class oscP5.OscP5 +
Deprecated.   +
newMsg(String) - +Method in class oscP5.OscP5 +
Deprecated.   +
NONE - +Static variable in class oscP5.OscNetManager +
  +
now() - +Static method in class oscP5.OscBundle +
returns the current time in milliseconds. +
+
+

+O

+
+
OFF - +Static variable in class netP5.Logger +
  +
OFF - +Static variable in class oscP5.OscP5 +
  +
OFF - +Static variable in class oscP5.OscProperties +
  +
ON - +Static variable in class netP5.Logger +
  +
ON - +Static variable in class oscP5.OscP5 +
  +
ON - +Static variable in class oscP5.OscProperties +
  +
OscArgument - Class in oscP5
an osc argument contains one value of values from a received osc message.
OscArgument() - +Constructor for class oscP5.OscArgument +
  +
OscBundle - Class in oscP5
Osc Bundles are collections of Osc Messages.
OscBundle() - +Constructor for class oscP5.OscBundle +
instantiate a new OscBundle object. +
oscEvent(OscMessage) - +Method in interface oscP5.OscEventListener +
  +
OscEventListener - Interface in oscP5
 
OscIn - Class in oscP5
Deprecated. 
OscIn(OscMessage) - +Constructor for class oscP5.OscIn +
Deprecated.   +
OscMessage - Class in oscP5
An OSC message consists of an OSC Address Pattern, an OSC Type Tag String + and the OSC arguments.
OscMessage(OscMessage) - +Constructor for class oscP5.OscMessage +
  +
OscMessage(String) - +Constructor for class oscP5.OscMessage +
  +
OscMessage(int) - +Constructor for class oscP5.OscMessage +
  +
OscMessage(String, Object[]) - +Constructor for class oscP5.OscMessage +
  +
OscMessage(int, Object[]) - +Constructor for class oscP5.OscMessage +
  +
OscNetManager - Class in oscP5
 
OscNetManager() - +Constructor for class oscP5.OscNetManager +
  +
oscP5 - package oscP5
 
OscP5 - Class in oscP5
TODO add better error message handling for oscEvents, see this post + http://forum.processing.org/topic/oscp5-major-problems-with-error-handling# 25080000000811163
OscP5(Object, OscProperties) - +Constructor for class oscP5.OscP5 +
  +
OscP5(Object, String, int, int) - +Constructor for class oscP5.OscP5 +
  +
OscP5(Object, int, int) - +Constructor for class oscP5.OscP5 +
  +
OscP5(Object, int) - +Constructor for class oscP5.OscP5 +
  +
OscP5(Object, String, int, int, String) - +Constructor for class oscP5.OscP5 +
Deprecated.   +
OscP5(Object, String, int) - +Constructor for class oscP5.OscP5 +
Deprecated.   +
OSCP5_CLOSED - +Static variable in class oscP5.OscStatus +
  +
OscPacket - Class in oscP5
 
OscPacket() - +Constructor for class oscP5.OscPacket +
  +
OscPatcher - Class in oscP5
 
OscPlug - Class in oscP5
 
OscPlug() - +Constructor for class oscP5.OscPlug +
  +
OscProperties - Class in oscP5
osc properties are used to start oscP5 with more specific settings.
OscProperties(OscEventListener) - +Constructor for class oscP5.OscProperties +
  +
OscProperties() - +Constructor for class oscP5.OscProperties +
create a new OscProperties Object. +
oscStatus(OscStatus) - +Method in interface oscP5.OscEventListener +
  +
OscStatus - Class in oscP5
 
OscStatus(int) - +Constructor for class oscP5.OscStatus +
  +
+
+

+P

+
+
plug(Object, String, String, String) - +Method in class oscP5.OscP5 +
osc messages can be automatically forwarded to a specific method of an object. +
plug(Object, String, String) - +Method in class oscP5.OscP5 +
  +
plug(Object, String, String) - +Method in class oscP5.OscPlug +
  +
plug(Object, String, String, String) - +Method in class oscP5.OscPlug +
  +
port() - +Method in class netP5.NetAddress +
returns the remote port number +
port() - +Method in class netP5.NetMessage +
get the port the net message was received at. +
port() - +Method in class oscP5.OscPacket +
  +
print(String) - +Static method in class netP5.Logger +
  +
print() - +Static method in class netP5.NetInfo +
  +
print() - +Method in class oscP5.OscMessage +
  +
printBytes(byte[]) - +Static method in class netP5.Bytes +
  +
printBytes(byte[]) - +Static method in class netP5.Logger +
  +
printData() - +Method in class oscP5.OscMessage +
  +
printDebug(String, String) - +Static method in class netP5.Logger +
  +
printError(String, String) - +Static method in class netP5.Logger +
  +
printInfo(String, String) - +Static method in class netP5.Logger +
  +
println(String) - +Static method in class netP5.Logger +
  +
printProcess(String, String) - +Static method in class netP5.Logger +
  +
printWarning(String, String) - +Static method in class netP5.Logger +
  +
process(TcpPacket, int) - +Method in class netP5.AbstractTcpServer +
  +
PROCESS - +Static variable in class netP5.Logger +
  +
process(DatagramPacket, int) - +Method in class netP5.Multicast +
  +
process(TcpPacket, int) - +Method in interface netP5.TcpPacketListener +
  +
process(DatagramPacket, int) - +Method in interface netP5.UdpPacketListener +
  +
process(DatagramPacket, int) - +Method in class netP5.UdpServer +
  +
process(DatagramPacket, int) - +Method in class oscP5.OscNetManager +
  +
process(TcpPacket, int) - +Method in class oscP5.OscNetManager +
  +
process(DatagramPacket, int) - +Method in class oscP5.OscP5 +
incoming osc messages from an udp socket are parsed, processed and forwarded to the parent. +
process(TcpPacket, int) - +Method in class oscP5.OscP5 +
  +
properties() - +Method in class oscP5.OscP5 +
returns the current properties of oscP5. +
protocol() - +Method in class netP5.NetMessage +
get the protocol type the message was sent over. +
+
+

+R

+
+
reconnect() - +Method in class netP5.AbstractTcpClient +
when a TCP connection is lost, reconnect to the server with reconnect(). +
remoteAddress() - +Method in class oscP5.OscProperties +
returns a NetAddress of the remote host you are sending + osc packets to. +
remove(AbstractTcpClient) - +Method in class netP5.AbstractTcpServer +
remove a TcpClient from the server's client list. +
remove(String, int) - +Method in class netP5.NetAddressList +
  +
remove(NetAddress) - +Method in class netP5.NetAddressList +
  +
remove(String, char) - +Static method in class netP5.StringUtils +
Removes all instances of a character in a String. +
remove(String, String) - +Static method in class netP5.StringUtils +
Removes all instances of a substring in a String. +
remove(String, String[]) - +Static method in class netP5.StringUtils +
Removes all instances of substrings in a String. +
remove(AbstractTcpClient) - +Method in interface netP5.TcpPacketListener +
  +
remove(int) - +Method in class oscP5.OscBundle +
remove an OscMessage from an OscBundle. +
remove(OscMessage) - +Method in class oscP5.OscBundle +
  +
remove(AbstractTcpClient) - +Method in class oscP5.OscNetManager +
  +
remove(AbstractTcpClient) - +Method in class oscP5.OscP5 +
  +
removeDuplicates(String, String) - +Static method in class netP5.StringUtils +
Removes duplicates of a substring in a String. +
removeListener(NetListener) - +Method in class netP5.Multicast +
  +
removeListener(NetListener) - +Method in class netP5.TcpServer +
  +
removeListener(NetListener) - +Method in class netP5.UdpServer +
  +
removeListener(OscEventListener) - +Method in class oscP5.OscP5 +
  +
removeTcpListener(TcpPacketListener) - +Method in class oscP5.OscNetManager +
  +
removeUdpListener(UdpPacketListener) - +Method in class oscP5.OscNetManager +
  +
replace(String, String, String) - +Static method in class netP5.StringUtils +
Replaces substrings in a string. +
replace(String, String[], String) - +Static method in class netP5.StringUtils +
Replaces several substrings in a string. +
right(String, String) - +Static method in class netP5.StringUtils +
Returns the substring to the right of the specified substring in the + specified String, starting from the left. +
rightBack(String, String) - +Static method in class netP5.StringUtils +
Returns the substring to the right of the specified substring in the + specified String, starting from the right. +
rightJustify(String, int) - +Static method in class netP5.StringUtils +
Creates a string of the given width with the given string right justified + (with an appropriate number of spaces before it). +
run() - +Method in class netP5.AbstractMulticast +
  +
run() - +Method in class netP5.AbstractTcpClient +
  +
run() - +Method in class netP5.AbstractTcpServer +
  +
run() - +Method in class netP5.AbstractUdpServer +
  +
+
+

+S

+
+
send(String) - +Method in class netP5.AbstractMulticast +
send a string to the multicast address. +
send(byte[]) - +Method in class netP5.AbstractMulticast +
send a byte array to the mulitcast address. +
send(byte[]) - +Method in class netP5.AbstractTcpClient +
  +
send(byte[][]) - +Method in class netP5.AbstractTcpClient +
  +
send(String) - +Method in class netP5.AbstractTcpClient +
  +
send(String) - +Method in class netP5.AbstractTcpServer +
send a string to the connected client(s). +
send(byte[]) - +Method in class netP5.AbstractTcpServer +
send a byte array to the connected client(s). +
send(String) - +Method in class netP5.AbstractUdpClient +
send a string using UDP to an already specified RemoteAddress. +
send(byte[]) - +Method in class netP5.AbstractUdpClient +
send a byte array using UDP to an already specified RemoteAddress. +
send(byte[], NetAddress) - +Method in class netP5.AbstractUdpClient +
send a byte array to the dedicated remoteAddress. +
send(byte[], String, int) - +Method in class netP5.AbstractUdpClient +
send a byte array to the dedicated remoteAddress. +
send(DatagramPacket) - +Method in class netP5.AbstractUdpClient +
  +
send(byte[], InetAddress, int) - +Method in class netP5.AbstractUdpClient +
send a byte array to the dedicated remoteAddress. +
send(byte[]) - +Method in class netP5.AbstractUdpServer +
send a byte array to a previously defined remoteAddress. +
send(byte[], String, int) - +Method in class netP5.AbstractUdpServer +
send a byte array to a dedicated remoteAddress. +
send(DatagramPacket) - +Method in class netP5.AbstractUdpServer +
  +
send(byte[], InetAddress, int) - +Method in class netP5.AbstractUdpServer +
send a byte array to a dedicated remoteAddress. +
send(OscPacket) - +Method in class oscP5.OscNetManager +
  +
send(DatagramPacket) - +Method in class oscP5.OscNetManager +
  +
send(OscPacket, String, int) - +Method in class oscP5.OscNetManager +
  +
send(OscPacket, NetAddressList) - +Method in class oscP5.OscNetManager +
  +
send(OscPacket, NetAddress) - +Method in class oscP5.OscNetManager +
  +
send(String, Object[]) - +Method in class oscP5.OscNetManager +
  +
send(String, Object[], String, int) - +Method in class oscP5.OscNetManager +
  +
send(String, Object[], NetAddressList) - +Method in class oscP5.OscNetManager +
  +
send(String, Object[], NetAddress) - +Method in class oscP5.OscNetManager +
  +
send(OscPacket, NetAddress) - +Method in class oscP5.OscP5 +
you can send osc packets in many different ways. +
send(OscPacket) - +Method in class oscP5.OscP5 +
  +
send(OscPacket, NetAddressList) - +Method in class oscP5.OscP5 +
  +
send(String, Object[]) - +Method in class oscP5.OscP5 +
  +
send(String, Object[], NetAddressList) - +Method in class oscP5.OscP5 +
  +
send(String, Object[], NetAddress) - +Method in class oscP5.OscP5 +
  +
send(String, Object[], String, int) - +Method in class oscP5.OscP5 +
  +
send(OscPacket, TcpClient) - +Method in class oscP5.OscP5 +
send to tcp client +
send(String, Object[], TcpClient) - +Method in class oscP5.OscP5 +
  +
send(OscPacket, String, int) - +Method in class oscP5.OscP5 +
Deprecated.   +
SEND_FAILED - +Static variable in class netP5.NetStatus +
  +
SEND_FAILED - +Static variable in class oscP5.OscStatus +
  +
sendStatus() - +Method in class oscP5.OscProperties +
  +
SERVER_CLOSED - +Static variable in class netP5.NetStatus +
  +
SERVER_CLOSED - +Static variable in class oscP5.OscStatus +
  +
serverport() - +Method in class netP5.AbstractTcpClient +
get the server port. +
set(int, int) - +Static method in class netP5.Logger +
  +
set(NetAddress[]) - +Method in class netP5.NetAddressList +
  +
set(int, Object) - +Method in class oscP5.OscMessage +
TODO + set should enable the programmer to set values + of an existing osc message. +
setAddrPattern(String) - +Method in class oscP5.OscMessage +
set the address pattern of an osc message. +
setAddrPattern(int) - +Method in class oscP5.OscMessage +
  +
setArguments(Object[]) - +Method in class oscP5.OscMessage +
set the arguments of the osc message using an object array. +
setDatagramSize(int) - +Method in class netP5.AbstractMulticast +
set the buffer size of the datagrams received by the multicast socket. +
setDatagramSize(int) - +Method in class oscP5.OscProperties +
set the size of the datagrampacket byte buffer. +
setEventMethod(String) - +Method in class oscP5.OscProperties +
set the name of the default event method. +
setListeningPort(int) - +Method in class oscP5.OscProperties +
set port number you are listening for incoming osc packets. +
setLogStatus(int, int) - +Static method in class oscP5.OscP5 +
oscP5 has a logging mechanism which prints out processes, warnings and errors into the + console window. +
setLogStatus(int) - +Static method in class oscP5.OscP5 +
  +
setLoopback(boolean) - +Method in class netP5.AbstractMulticast +
Disable/Enable local loopback of multicast datagrams. +
setName(String) - +Method in class netP5.TcpClient +
  +
setNetworkProtocol(int) - +Method in class oscP5.OscProperties +
set the network protocol over which osc messages are transmitted. +
setRemoteAddress(String, int) - +Method in class oscP5.OscProperties +
set the remote host address. +
setRemoteAddress(NetAddress) - +Method in class oscP5.OscProperties +
set the remote host address. +
setSRSP(boolean) - +Method in class oscP5.OscProperties +
SRSP stand for Send and Receive on Same Port. +
setTerminator(char) - +Method in class netP5.AbstractTcpClient +
to parse an incomming tcp message, a terminator character is required to + determine the end of the message so that it can be parsed and forwarded. +
setTimetag(long) - +Method in class oscP5.OscBundle +
set the timetag of an osc bundle. +
setTimeToLive(int) - +Method in class netP5.AbstractMulticast +
Set the default time-to-live for multicast packets + sent out on this MulticastSocket in order to control the scope + of the multicasts. +
setTimeToLive(int) - +Method in class oscP5.OscNetManager +
  +
setTimeToLive(int) - +Method in class oscP5.OscP5 +
set timeToLive of a multicast packet. +
size() - +Method in class netP5.AbstractTcpServer +
get the number of connected clients. +
size() - +Method in class netP5.NetAddressList +
  +
size() - +Method in class oscP5.OscBundle +
get the size of the osc bundle array which contains the osc messages. +
slice(int, String[]) - +Static method in class netP5.StringUtils +
  +
socket() - +Method in class netP5.AbstractMulticast +
get the running multicast socket. +
socket() - +Method in class netP5.AbstractTcpClient +
get the instance of the socket. +
socket() - +Method in class netP5.AbstractTcpServer +
get the server socket object. +
socket() - +Method in class netP5.AbstractUdpClient +
get the datagram socket of the UDP client. +
socket() - +Method in class netP5.AbstractUdpServer +
get the datagram socket of the UDP server. +
spaces(int) - +Static method in class netP5.StringUtils +
Returns a String with the specified number of spaces. +
srsp() - +Method in class oscP5.OscProperties +
you can send and receive at the same port while on a udp con +
start() - +Method in class netP5.AbstractMulticast +
  +
start() - +Method in class netP5.AbstractUdpServer +
  +
start(OscProperties) - +Method in class oscP5.OscNetManager +
  +
status(int) - +Method in interface netP5.TcpPacketListener +
  +
status(int) - +Method in class netP5.TcpServer +
  +
status(int) - +Method in class oscP5.OscNetManager +
  +
status(int) - +Method in class oscP5.OscP5 +
  +
stop() - +Method in class oscP5.OscP5 +
stop oscP5 and close open Sockets. +
StringUtils - Class in netP5
 
stringValue() - +Method in class oscP5.OscArgument +
get the String value of the osc argument. +
switchCase(String) - +Static method in class netP5.StringUtils +
Switches the case of the supplied String. +
switchCase(char) - +Static method in class netP5.StringUtils +
Switches the case of the supplied character. +
+
+

+T

+
+
TCP - +Static variable in interface netP5.NetP5 +
  +
TCP - +Static variable in class oscP5.OscP5 +
a static variable used when creating an oscP5 instance with a sepcified network protocol. +
TCP - +Static variable in class oscP5.OscProperties +
  +
TcpClient - Class in netP5
 
TcpClient(Object, String, int) - +Constructor for class netP5.TcpClient +
  +
TcpClient(Object, String, int, int) - +Constructor for class netP5.TcpClient +
  +
TcpClient(TcpPacketListener, String, int, int) - +Constructor for class netP5.TcpClient +
  +
TcpClient(Object, NetAddress) - +Constructor for class netP5.TcpClient +
  +
TcpClient(NetAddress) - +Constructor for class netP5.TcpClient +
  +
TcpClient(String, int) - +Constructor for class netP5.TcpClient +
  +
TcpClient(AbstractTcpServer, Socket, TcpPacketListener, int, int) - +Constructor for class netP5.TcpClient +
  +
tcpClient() - +Method in class oscP5.OscNetManager +
  +
tcpClient() - +Method in class oscP5.OscP5 +
return the instance of the running TCP client if in TCP mode. +
tcpConnection() - +Method in class netP5.NetMessage +
  +
tcpConnection() - +Method in class oscP5.OscPacket +
when in TCP mode, tcpConnection() returns the instance of the TcpClient that has sent the OscMessage. +
TcpPacket - Class in netP5
 
TcpPacket(TcpClient, StringBuffer, byte[]) - +Constructor for class netP5.TcpPacket +
  +
TcpPacketListener - Interface in netP5
 
TcpServer - Class in netP5
 
TcpServer(int) - +Constructor for class netP5.TcpServer +
  +
TcpServer(Object, int) - +Constructor for class netP5.TcpServer +
  +
TcpServer(Object, int, int) - +Constructor for class netP5.TcpServer +
  +
TcpServer(int, int) - +Constructor for class netP5.TcpServer +
  +
TcpServer(TcpPacketListener, int, int) - +Constructor for class netP5.TcpServer +
  +
tcpServer() - +Method in class oscP5.OscNetManager +
  +
tcpServer() - +Method in class oscP5.OscP5 +
return the instance of the running TCP server if in TCP mode. +
timetag() - +Method in class oscP5.OscBundle +
returns a timetag as byte array. +
timetag() - +Method in class oscP5.OscMessage +
get the timetag of an osc message. +
timeToLive() - +Method in class netP5.AbstractMulticast +
get the current time to live value. +
toByteArray(InputStream) - +Static method in class netP5.Bytes +
  +
toBytes(int) - +Static method in class netP5.Bytes +
  +
toBytes(int, byte[]) - +Static method in class netP5.Bytes +
  +
toBytes(long) - +Static method in class netP5.Bytes +
  +
toBytes(long, byte[]) - +Static method in class netP5.Bytes +
  +
toDouble(byte[]) - +Static method in class netP5.Bytes +
  +
toFile(InputStream, File) - +Static method in class netP5.Bytes +
  +
toFloat(byte[]) - +Static method in class netP5.Bytes +
  +
toInt(byte[]) - +Static method in class netP5.Bytes +
  +
toIntBigEndian(InputStream) - +Static method in class netP5.Bytes +
  +
toIntLittleEndian(InputStream) - +Static method in class netP5.Bytes +
  +
toLong(byte[]) - +Static method in class netP5.Bytes +
  +
toStream(OutputStream, int) - +Static method in class netP5.Bytes +
  +
toStream(OutputStream, String) - +Static method in class netP5.Bytes +
  +
toStream(OutputStream, byte[]) - +Static method in class netP5.Bytes +
  +
toStream(OutputStream, File) - +Static method in class netP5.Bytes +
  +
toString(byte[], int, int) - +Static method in class netP5.Bytes +
  +
toString(byte[]) - +Static method in class netP5.Bytes +
  +
toString(InputStream) - +Static method in class netP5.Bytes +
  +
toString() - +Method in class netP5.NetAddress +
  +
toString() - +Method in class oscP5.OscArgument +
  +
toString() - +Method in class oscP5.OscMessage +
  +
toString() - +Method in class oscP5.OscProperties +
prints out the current osc properties settings. +
typetag() - +Method in class oscP5.OscMessage +
returns the typetag of the osc message. +
+
+

+U

+
+
UDP - +Static variable in interface netP5.NetP5 +
  +
UDP - +Static variable in class oscP5.OscP5 +
a static variable used when creating an oscP5 instance with a sepcified network protocol. +
UDP - +Static variable in class oscP5.OscProperties +
  +
UdpClient - Class in netP5
 
UdpClient() - +Constructor for class netP5.UdpClient +
  +
UdpClient(String, int) - +Constructor for class netP5.UdpClient +
  +
UdpClient(NetAddress) - +Constructor for class netP5.UdpClient +
  +
UdpPacketListener - Interface in netP5
 
UdpServer - Class in netP5
 
UdpServer(Object, int, int) - +Constructor for class netP5.UdpServer +
new UDP server. +
UdpServer(Object, int) - +Constructor for class netP5.UdpServer +
  +
UdpServer(UdpPacketListener, int, int) - +Constructor for class netP5.UdpServer +
  +
unBan(String) - +Method in class netP5.AbstractTcpServer +
remove the ban for an IP address. +
+
+

+V

+
+
VERSION - +Static variable in interface netP5.NetP5 +
  +
VERSION - +Static variable in class oscP5.OscP5 +
  +
version() - +Method in class oscP5.OscP5 +
get the current version of oscP5. +
+
+

+W

+
+
wan() - +Static method in class netP5.NetInfo +
  +
WARNING - +Static variable in class netP5.Logger +
  +
+
+A B C D E F G H I L M N O P R S T U V W + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/index.html b/libraries/oscP5/reference/index.html new file mode 100644 index 0000000..41a7d02 --- /dev/null +++ b/libraries/oscP5/reference/index.html @@ -0,0 +1,39 @@ + + + + + + +Javadocs: oscP5 + + + + + + + + + + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to<A HREF="overview-summary.html">Non-frame version.</A> + + + diff --git a/libraries/oscP5/reference/netP5/AbstractMulticast.html b/libraries/oscP5/reference/netP5/AbstractMulticast.html new file mode 100644 index 0000000..7de48fc --- /dev/null +++ b/libraries/oscP5/reference/netP5/AbstractMulticast.html @@ -0,0 +1,560 @@ + + + + + + +AbstractMulticast (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class AbstractMulticast

+
+java.lang.Object
+  extended by netP5.AbstractMulticast
+
+
+
All Implemented Interfaces:
Runnable
+
+
+
Direct Known Subclasses:
Multicast
+
+
+
+
public abstract class AbstractMulticast
extends Object
implements Runnable
+ + +

+


+ +

+ + + + + + + + + + + + + + +
+Constructor Summary
AbstractMulticast(UdpPacketListener theDatagramListener, + String theMulticastAddress, + int thePort) + +
+           
AbstractMulticast(UdpPacketListener theDatagramListener, + String theMulticastAddress, + int thePort, + int theBufferSize) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidclose() + +
+           
+ voiddispose() + +
+          dispose the multicastSocket.
+ booleanloopback() + +
+          get the current loopback mode.
+ voidrun() + +
+           
+ voidsend(byte[] theBytes) + +
+          send a byte array to the mulitcast address.
+ voidsend(String theString) + +
+          send a string to the multicast address.
+ voidsetDatagramSize(int theDatagramSize) + +
+          set the buffer size of the datagrams received by the multicast socket.
+ voidsetLoopback(boolean theFlag) + +
+          Disable/Enable local loopback of multicast datagrams.
+ booleansetTimeToLive(int theTTL) + +
+          Set the default time-to-live for multicast packets + sent out on this MulticastSocket in order to control the scope + of the multicasts.
+ MulticastSocketsocket() + +
+          get the running multicast socket.
+ voidstart() + +
+           
+ inttimeToLive() + +
+          get the current time to live value.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+AbstractMulticast

+
+public AbstractMulticast(UdpPacketListener theDatagramListener,
+                         String theMulticastAddress,
+                         int thePort,
+                         int theBufferSize)
+
+
+
Parameters:
theDatagramListener - UdpPacketListener
theMulticastAddress - String
thePort - int
theBufferSize - int
+
+
+ +

+AbstractMulticast

+
+public AbstractMulticast(UdpPacketListener theDatagramListener,
+                         String theMulticastAddress,
+                         int thePort)
+
+
+
Parameters:
theDatagramListener - UdpPacketListener
theMulticastAddress - String
thePort - int
+
+ + + + + + + + +
+Method Detail
+ +

+socket

+
+public MulticastSocket socket()
+
+
get the running multicast socket. +

+

+
+
+
+ +
Returns:
MulticastSocket
+
+
+
+ +

+setDatagramSize

+
+public void setDatagramSize(int theDatagramSize)
+
+
set the buffer size of the datagrams received by the multicast socket. +

+

+
+
+
+
Parameters:
theDatagramSize - int
+
+
+
+ +

+start

+
+public void start()
+
+
+
+
+
+
+
+
+
+ +

+run

+
+public void run()
+
+
+
Specified by:
run in interface Runnable
+
+
+
+
+
+
+ +

+dispose

+
+public void dispose()
+
+
dispose the multicastSocket. +

+

+
+
+
+
+
+
+
+ +

+close

+
+public void close()
+
+
+
+
+
+
+
+
+
+ +

+setTimeToLive

+
+public boolean setTimeToLive(int theTTL)
+
+
Set the default time-to-live for multicast packets + sent out on this MulticastSocket in order to control the scope + of the multicasts. theTTL must be in the range 0 <= ttl <= 255 +

+

+
+
+
+
Parameters:
theTTL - int +
Returns:
boolean
+
+
+
+ +

+timeToLive

+
+public int timeToLive()
+
+
get the current time to live value. +

+

+
+
+
+ +
Returns:
int
+
+
+
+ +

+setLoopback

+
+public void setLoopback(boolean theFlag)
+
+
Disable/Enable local loopback of multicast datagrams. + The option is used by the platform's networking code as a + hint for setting whether multicast data will be + looped back to the local socket. +

+

+
+
+
+
Parameters:
theFlag - boolean
+
+
+
+ +

+loopback

+
+public boolean loopback()
+
+
get the current loopback mode. messages loop back to the local address + if the loopback is set to false. set loopback to false to prevent messages + to loop back to your local address. +

+

+
+
+
+ +
Returns:
boolean
+
+
+
+ +

+send

+
+public void send(String theString)
+
+
send a string to the multicast address. +

+

+
+
+
+
Parameters:
theString - String
+
+
+
+ +

+send

+
+public void send(byte[] theBytes)
+
+
send a byte array to the mulitcast address. +

+

+
+
+
+
Parameters:
theBytes - byte[]
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/AbstractTcpClient.html b/libraries/oscP5/reference/netP5/AbstractTcpClient.html new file mode 100644 index 0000000..afc5010 --- /dev/null +++ b/libraries/oscP5/reference/netP5/AbstractTcpClient.html @@ -0,0 +1,869 @@ + + + + + + +AbstractTcpClient (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class AbstractTcpClient

+
+java.lang.Object
+  extended by netP5.AbstractTcpClient
+
+
+
All Implemented Interfaces:
Runnable
+
+
+
Direct Known Subclasses:
TcpClient
+
+
+
+
public abstract class AbstractTcpClient
extends Object
implements Runnable
+ + +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static intMODE_NEWLINE + +
+          terminator is newline.
+static intMODE_READLINE + +
+          terminator is readline.
+static intMODE_STREAM + +
+          no terminator required, packets are sent via + a tcp stream.
+static intMODE_TERMINATED + +
+          terminator is terminated, by default this is character '\0' + and can be set with setTerminator
+  + + + + + + + + + + + + + + + + + + + + + + +
+Constructor Summary
AbstractTcpClient(AbstractTcpServer theTcpServer, + Socket theSocket, + TcpPacketListener theTcpPacketListener, + int theServerPort, + int theMode) + +
+           
AbstractTcpClient(String theHost, + int thePort) + +
+           
AbstractTcpClient(String theHost, + int thePort, + int theMode) + +
+           
AbstractTcpClient(TcpPacketListener theTcpPacketListener, + String theHost, + int thePort) + +
+           
AbstractTcpClient(TcpPacketListener theTcpPacketListener, + String theHost, + int thePort, + int theMode) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voiddispose() + +
+          stop and dispose a tcp client.
+ booleanequals(NetAddress theNetAddress) + +
+           
+ booleanequals(TcpClient theClient) + +
+           
+ StringgetString() + +
+           
+ StringBuffergetStringBuffer() + +
+           
+abstract  voidhandleInput() + +
+           
+abstract  voidhandleStatus(int theIndex) + +
+           
+ TcpPacketListenerlistener() + +
+           
+ intmode() + +
+          get the mode of the terminator.
+ NetAddressnetaddress() + +
+          Deprecated.  
+ NetAddressnetAddress() + +
+           
+ voidreconnect() + +
+          when a TCP connection is lost, reconnect to the server with reconnect().
+ voidrun() + +
+           
+ voidsend(byte[] theBytes) + +
+           
+ voidsend(byte[][] theBytes) + +
+           
+ voidsend(String theString) + +
+           
+ intserverport() + +
+          get the server port.
+ voidsetTerminator(char theTerminator) + +
+          to parse an incomming tcp message, a terminator character is required to + determine the end of the message so that it can be parsed and forwarded.
+ Socketsocket() + +
+          get the instance of the socket.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+MODE_READLINE

+
+public static final int MODE_READLINE
+
+
terminator is readline. +

+

+
See Also:
Constant Field Values
+
+
+ +

+MODE_TERMINATED

+
+public static final int MODE_TERMINATED
+
+
terminator is terminated, by default this is character '\0' + and can be set with setTerminator +

+

+
See Also:
Constant Field Values
+
+
+ +

+MODE_NEWLINE

+
+public static final int MODE_NEWLINE
+
+
terminator is newline. +

+

+
See Also:
Constant Field Values
+
+
+ +

+MODE_STREAM

+
+public static final int MODE_STREAM
+
+
no terminator required, packets are sent via + a tcp stream. +

+

+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+AbstractTcpClient

+
+public AbstractTcpClient(TcpPacketListener theTcpPacketListener,
+                         String theHost,
+                         int thePort)
+
+
+
Parameters:
theTcpPacketListener - TcpPacketListener
theHost - String
thePort - int
+
+
+ +

+AbstractTcpClient

+
+public AbstractTcpClient(String theHost,
+                         int thePort)
+
+
+
Parameters:
theHost - String
thePort - int
+
+
+ +

+AbstractTcpClient

+
+public AbstractTcpClient(TcpPacketListener theTcpPacketListener,
+                         String theHost,
+                         int thePort,
+                         int theMode)
+
+
+
Parameters:
theTcpPacketListener - TcpPacketListener
theHost - String
thePort - int
theMode - int
+
+
+ +

+AbstractTcpClient

+
+public AbstractTcpClient(String theHost,
+                         int thePort,
+                         int theMode)
+
+
+
Parameters:
theHost - String
thePort - int
theMode - int
+
+
+ +

+AbstractTcpClient

+
+public AbstractTcpClient(AbstractTcpServer theTcpServer,
+                         Socket theSocket,
+                         TcpPacketListener theTcpPacketListener,
+                         int theServerPort,
+                         int theMode)
+
+
+
Parameters:
theTcpServer - AbstractTcpServer
theSocket - Socket
theTcpPacketListener - TcpPacketListener
theServerPort - int
theMode - int
+
+ + + + + + + + +
+Method Detail
+ +

+reconnect

+
+public void reconnect()
+
+
when a TCP connection is lost, reconnect to the server with reconnect(). +

+

+
+
+
+
+
+
+
+ +

+setTerminator

+
+public void setTerminator(char theTerminator)
+
+
to parse an incomming tcp message, a terminator character is required to + determine the end of the message so that it can be parsed and forwarded. +

+

+
+
+
+
Parameters:
theTerminator -
+
+
+
+ +

+dispose

+
+public void dispose()
+
+
stop and dispose a tcp client. +

+

+
+
+
+
+
+
+
+ +

+run

+
+public void run()
+
+
+
Specified by:
run in interface Runnable
+
+
+
+
+
+
+ +

+handleInput

+
+public abstract void handleInput()
+
+
+
+
+
+
+
+
+
+ +

+handleStatus

+
+public abstract void handleStatus(int theIndex)
+
+
+
+
+
+
Parameters:
theIndex -
+
+
+
+ +

+listener

+
+public TcpPacketListener listener()
+
+
+
+
+
+ +
Returns:
+
+
+
+ +

+serverport

+
+public int serverport()
+
+
get the server port. +

+

+
+
+
+ +
Returns:
+
+
+
+ +

+socket

+
+public Socket socket()
+
+
get the instance of the socket. more info at java.net.Socket +

+

+
+
+
+ +
Returns:
+
+
+
+ +

+mode

+
+public int mode()
+
+
get the mode of the terminator. +

+

+
+
+
+ +
Returns:
+
+
+
+ +

+getString

+
+public String getString()
+
+
+
+
+
+
+
+
+
+ +

+getStringBuffer

+
+public StringBuffer getStringBuffer()
+
+
+
+
+
+
+
+
+
+ +

+send

+
+public void send(byte[] theBytes)
+
+
+
+
+
+
+
+
+
+ +

+send

+
+public void send(byte[][] theBytes)
+
+
+
+
+
+
+
+
+
+ +

+send

+
+public void send(String theString)
+
+
+
+
+
+
+
+
+
+ +

+netAddress

+
+public NetAddress netAddress()
+
+
+
+
+
+
+
+
+
+ +

+netaddress

+
+public NetAddress netaddress()
+
+
Deprecated.  +

+

+
+
+
+ +
Returns:
NetAddress
+
+
+
+ +

+equals

+
+public boolean equals(NetAddress theNetAddress)
+
+
+
+
+
+
Parameters:
theNetAddress - NetAddress +
Returns:
boolean
+
+
+
+ +

+equals

+
+public boolean equals(TcpClient theClient)
+
+
+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/AbstractTcpServer.html b/libraries/oscP5/reference/netP5/AbstractTcpServer.html new file mode 100644 index 0000000..cd55883 --- /dev/null +++ b/libraries/oscP5/reference/netP5/AbstractTcpServer.html @@ -0,0 +1,675 @@ + + + + + + +AbstractTcpServer (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class AbstractTcpServer

+
+java.lang.Object
+  extended by netP5.AbstractTcpServer
+
+
+
All Implemented Interfaces:
Runnable, TcpPacketListener
+
+
+
Direct Known Subclasses:
TcpServer
+
+
+
+
public abstract class AbstractTcpServer
extends Object
implements Runnable, TcpPacketListener
+ + +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static intMODE_NEWLINE + +
+           
+static intMODE_READLINE + +
+           
+static intMODE_STREAM + +
+           
+static intMODE_TERMINATED + +
+           
+  + + + + + + + + + + + + + +
+Constructor Summary
AbstractTcpServer(int thePort, + int theMode) + +
+           
AbstractTcpServer(TcpPacketListener theTcpPacketListener, + int thePort, + int theMode) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidban(String theIP) + +
+          ban an IP address from the server.
+ voiddispose() + +
+          kill the server.
+ TcpClientgetClient(int theIndex) + +
+          get a client at a specific position the client list.
+ TcpClient[]getClients() + +
+          get a list of all connected clients.
+abstract  voidhandleInput(TcpPacket thePacket, + int thePort) + +
+           
+ voidprocess(TcpPacket thePacket, + int thePort) + +
+           
+ voidremove(AbstractTcpClient theTcpClient) + +
+          remove a TcpClient from the server's client list.
+ voidrun() + +
+           
+ voidsend(byte[] theBytes) + +
+          send a byte array to the connected client(s).
+ voidsend(String theString) + +
+          send a string to the connected client(s).
+ intsize() + +
+          get the number of connected clients.
+ ServerSocketsocket() + +
+          get the server socket object.
+ voidunBan(String theIP) + +
+          remove the ban for an IP address.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+ + + + + + + +
Methods inherited from interface netP5.TcpPacketListener
status
+  +

+ + + + + + + + +
+Field Detail
+ +

+MODE_READLINE

+
+public static final int MODE_READLINE
+
+
+
See Also:
Constant Field Values
+
+
+ +

+MODE_TERMINATED

+
+public static final int MODE_TERMINATED
+
+
+
See Also:
Constant Field Values
+
+
+ +

+MODE_NEWLINE

+
+public static final int MODE_NEWLINE
+
+
+
See Also:
Constant Field Values
+
+
+ +

+MODE_STREAM

+
+public static final int MODE_STREAM
+
+
+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+AbstractTcpServer

+
+public AbstractTcpServer(int thePort,
+                         int theMode)
+
+
+
Parameters:
thePort - int
theMode - int
+
+
+ +

+AbstractTcpServer

+
+public AbstractTcpServer(TcpPacketListener theTcpPacketListener,
+                         int thePort,
+                         int theMode)
+
+
+
Parameters:
theTcpPacketListener - TcpPacketListener
thePort - int
theMode - int
+
+ + + + + + + + +
+Method Detail
+ +

+ban

+
+public void ban(String theIP)
+
+
ban an IP address from the server. +

+

+
+
+
+
Parameters:
theIP -
+
+
+
+ +

+unBan

+
+public void unBan(String theIP)
+
+
remove the ban for an IP address. +

+

+
+
+
+
Parameters:
theIP -
+
+
+
+ +

+socket

+
+public ServerSocket socket()
+
+
get the server socket object. more at java.net.ServerSocket +

+

+
+
+
+ +
Returns:
+
+
+
+ +

+run

+
+public void run()
+
+
+
Specified by:
run in interface Runnable
+
+
+
+
+
+
+ +

+send

+
+public void send(String theString)
+
+
send a string to the connected client(s). +

+

+
+
+
+
Parameters:
theString -
+
+
+
+ +

+send

+
+public void send(byte[] theBytes)
+
+
send a byte array to the connected client(s). +

+

+
+
+
+
Parameters:
theBytes -
+
+
+
+ +

+dispose

+
+public void dispose()
+
+
kill the server. +

+

+
+
+
+
+
+
+
+ +

+size

+
+public int size()
+
+
get the number of connected clients. +

+

+
+
+
+ +
Returns:
+
+
+
+ +

+getClients

+
+public TcpClient[] getClients()
+
+
get a list of all connected clients. an array of type TcpClient[] + will be returned. +

+

+
+
+
+ +
Returns:
+
+
+
+ +

+getClient

+
+public TcpClient getClient(int theIndex)
+
+
get a client at a specific position the client list. +

+

+
+
+
+
Parameters:
theIndex - +
Returns:
+
+
+
+ +

+process

+
+public void process(TcpPacket thePacket,
+                    int thePort)
+
+
+
Specified by:
process in interface TcpPacketListener
+
+
+
Parameters:
thePacket - TcpPacket
thePort - int
+
+
+
+ +

+handleInput

+
+public abstract void handleInput(TcpPacket thePacket,
+                                 int thePort)
+
+
+
+
+
+
Parameters:
thePacket - TcpPacket
thePort - int
+
+
+
+ +

+remove

+
+public void remove(AbstractTcpClient theTcpClient)
+
+
remove a TcpClient from the server's client list. +

+

+
Specified by:
remove in interface TcpPacketListener
+
+
+
Parameters:
theTcpClient - TCPClientAbstract
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/AbstractUdpClient.html b/libraries/oscP5/reference/netP5/AbstractUdpClient.html new file mode 100644 index 0000000..44efe19 --- /dev/null +++ b/libraries/oscP5/reference/netP5/AbstractUdpClient.html @@ -0,0 +1,408 @@ + + + + + + +AbstractUdpClient (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class AbstractUdpClient

+
+java.lang.Object
+  extended by netP5.AbstractUdpClient
+
+
+
Direct Known Subclasses:
UdpClient
+
+
+
+
public abstract class AbstractUdpClient
extends Object
+ + +

+


+ +

+ + + + + + + + + + + + + + +
+Constructor Summary
AbstractUdpClient() + +
+           
AbstractUdpClient(String theAddr, + int thePort) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidsend(byte[] theBytes) + +
+          send a byte array using UDP to an already specified RemoteAddress.
+ voidsend(byte[] theBytes, + InetAddress theAddress, + int thePort) + +
+          send a byte array to the dedicated remoteAddress.
+ voidsend(byte[] theBytes, + NetAddress theNetAddress) + +
+          send a byte array to the dedicated remoteAddress.
+ voidsend(byte[] theBytes, + String theAddress, + int thePort) + +
+          send a byte array to the dedicated remoteAddress.
+ voidsend(DatagramPacket thePacket) + +
+           
+ voidsend(String theString) + +
+          send a string using UDP to an already specified RemoteAddress.
+ DatagramSocketsocket() + +
+          get the datagram socket of the UDP client.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+AbstractUdpClient

+
+public AbstractUdpClient()
+
+
+
+ +

+AbstractUdpClient

+
+public AbstractUdpClient(String theAddr,
+                         int thePort)
+
+
+
Parameters:
theAddr - String
thePort - int
+
+ + + + + + + + +
+Method Detail
+ +

+socket

+
+public DatagramSocket socket()
+
+
get the datagram socket of the UDP client. more info at java.net.DatagramSocket +

+

+ +
Returns:
DatagramSocket
+
+
+
+ +

+send

+
+public void send(String theString)
+
+
send a string using UDP to an already specified RemoteAddress. +

+

+
Parameters:
theString -
+
+
+
+ +

+send

+
+public void send(byte[] theBytes)
+
+
send a byte array using UDP to an already specified RemoteAddress. +

+

+
Parameters:
theBytes - byte[]
+
+
+
+ +

+send

+
+public void send(byte[] theBytes,
+                 NetAddress theNetAddress)
+
+
send a byte array to the dedicated remoteAddress. +

+

+
Parameters:
theBytes -
theNetAddress -
+
+
+
+ +

+send

+
+public void send(byte[] theBytes,
+                 String theAddress,
+                 int thePort)
+
+
send a byte array to the dedicated remoteAddress. +

+

+
Parameters:
thePacket - OscPacket
theAddress - String
thePort - int
+
+
+
+ +

+send

+
+public void send(DatagramPacket thePacket)
+
+
+
Parameters:
thePacket - DatagramPacket
+
+
+
+ +

+send

+
+public void send(byte[] theBytes,
+                 InetAddress theAddress,
+                 int thePort)
+
+
send a byte array to the dedicated remoteAddress. +

+

+
Parameters:
theBytes - byte[]
theAddress - InetAddress
thePort - int
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/AbstractUdpServer.html b/libraries/oscP5/reference/netP5/AbstractUdpServer.html new file mode 100644 index 0000000..927c9cb --- /dev/null +++ b/libraries/oscP5/reference/netP5/AbstractUdpServer.html @@ -0,0 +1,440 @@ + + + + + + +AbstractUdpServer (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class AbstractUdpServer

+
+java.lang.Object
+  extended by netP5.AbstractUdpServer
+
+
+
All Implemented Interfaces:
Runnable
+
+
+
Direct Known Subclasses:
UdpServer
+
+
+
+
public abstract class AbstractUdpServer
extends Object
implements Runnable
+ + +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
AbstractUdpServer(UdpPacketListener theListener, + int thePort, + int theBufferSize) + +
+          create a new UdpServer
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voiddispose() + +
+          stop the UDP server, clean up and delete its reference.
+ voidrun() + +
+           
+ voidsend(byte[] theBytes) + +
+          send a byte array to a previously defined remoteAddress.
+ voidsend(byte[] theBytes, + InetAddress theAddress, + int thePort) + +
+          send a byte array to a dedicated remoteAddress.
+ voidsend(byte[] theBytes, + String theAddress, + int thePort) + +
+          send a byte array to a dedicated remoteAddress.
+ voidsend(DatagramPacket thePacket) + +
+           
+ DatagramSocketsocket() + +
+          get the datagram socket of the UDP server.
+ voidstart() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+AbstractUdpServer

+
+public AbstractUdpServer(UdpPacketListener theListener,
+                         int thePort,
+                         int theBufferSize)
+
+
create a new UdpServer +

+

+
Parameters:
theListener - UdpPacketListener
thePort - int
theBufferSize - int
+
+ + + + + + + + +
+Method Detail
+ +

+socket

+
+public DatagramSocket socket()
+
+
get the datagram socket of the UDP server. +

+

+
+
+
+ +
Returns:
DatagramSocket
+
+
+
+ +

+start

+
+public void start()
+
+
+
+
+
+
+
+
+
+ +

+run

+
+public void run()
+
+
+
Specified by:
run in interface Runnable
+
+
+
+
+
+
+ +

+dispose

+
+public void dispose()
+
+
stop the UDP server, clean up and delete its reference. +

+

+
+
+
+
+
+
+
+ +

+send

+
+public void send(byte[] theBytes)
+
+
send a byte array to a previously defined remoteAddress. +

+

+
+
+
+
Parameters:
theBytes - byte[]
+
+
+
+ +

+send

+
+public void send(byte[] theBytes,
+                 String theAddress,
+                 int thePort)
+
+
send a byte array to a dedicated remoteAddress. +

+

+
+
+
+
Parameters:
thePacket - OscPacket
theAddress - String
thePort - int
+
+
+
+ +

+send

+
+public void send(DatagramPacket thePacket)
+
+
+
+
+
+
Parameters:
thePacket - DatagramPacket
+
+
+
+ +

+send

+
+public void send(byte[] theBytes,
+                 InetAddress theAddress,
+                 int thePort)
+
+
send a byte array to a dedicated remoteAddress. +

+

+
+
+
+
Parameters:
theBytes - byte[]
theAddress - InetAddress
thePort - int
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/Bytes.html b/libraries/oscP5/reference/netP5/Bytes.html new file mode 100644 index 0000000..e3bdca7 --- /dev/null +++ b/libraries/oscP5/reference/netP5/Bytes.html @@ -0,0 +1,906 @@ + + + + + + +Bytes (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class Bytes

+
+java.lang.Object
+  extended by netP5.Bytes
+
+
+
+
public class Bytes
extends Object
+ + +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
Bytes() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static byte[]append(byte[] abyte0, + byte[] abyte1) + +
+           
+static byte[]append(byte[] abyte0, + byte[] abyte1, + byte[] abyte2) + +
+           
+static booleanareEqual(byte[] abyte0, + byte[] abyte1) + +
+           
+static byte[]copy(byte[] abyte0, + int i) + +
+           
+static byte[]copy(byte[] abyte0, + int i, + int j) + +
+           
+static StringgetAsString(byte[] theBytes) + +
+           
+static StringgetAsString(Object[] theObject) + +
+          converts an object array into a String that is formated like a list
+static voidmerge(byte[] abyte0, + byte[] abyte1) + +
+           
+static voidmerge(byte[] abyte0, + byte[] abyte1, + int i) + +
+           
+static voidmerge(byte[] abyte0, + byte[] abyte1, + int i, + int j) + +
+           
+static voidmerge(byte[] abyte0, + byte[] abyte1, + int i, + int j, + int k) + +
+           
+static voidprintBytes(byte[] byteArray) + +
+           
+static byte[]toByteArray(InputStream ins) + +
+           
+static byte[]toBytes(int i) + +
+           
+static byte[]toBytes(int i, + byte[] abyte0) + +
+           
+static byte[]toBytes(long l) + +
+           
+static byte[]toBytes(long l, + byte[] abyte0) + +
+           
+static doubletoDouble(byte[] abyte0) + +
+           
+static voidtoFile(InputStream ins, + File file) + +
+           
+static floattoFloat(byte[] abyte0) + +
+           
+static inttoInt(byte[] abyte0) + +
+           
+static inttoIntBigEndian(InputStream theInputStream) + +
+           
+static inttoIntLittleEndian(InputStream theInputStream) + +
+           
+static longtoLong(byte[] abyte0) + +
+           
+static voidtoStream(OutputStream os, + byte[] theBytes) + +
+           
+static voidtoStream(OutputStream os, + File file) + +
+           
+static voidtoStream(OutputStream os, + int i) + +
+           
+static voidtoStream(OutputStream os, + String s) + +
+           
+static StringtoString(byte[] abyte0) + +
+           
+static StringtoString(byte[] abyte0, + int i, + int j) + +
+           
+static StringtoString(InputStream ins) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+Bytes

+
+public Bytes()
+
+
+ + + + + + + + +
+Method Detail
+ +

+getAsString

+
+public static String getAsString(Object[] theObject)
+
+
converts an object array into a String that is formated like a list +

+

+
Parameters:
theObject - Object[] +
Returns:
String
+
+
+
+ +

+getAsString

+
+public static String getAsString(byte[] theBytes)
+
+
+
+
+
+
+ +

+toInt

+
+public static int toInt(byte[] abyte0)
+
+
+
+
+
+
+ +

+toLong

+
+public static long toLong(byte[] abyte0)
+
+
+
+
+
+
+ +

+toFloat

+
+public static float toFloat(byte[] abyte0)
+
+
+
+
+
+
+ +

+toDouble

+
+public static double toDouble(byte[] abyte0)
+
+
+
+
+
+
+ +

+toBytes

+
+public static byte[] toBytes(int i)
+
+
+
+
+
+
+ +

+toBytes

+
+public static byte[] toBytes(int i,
+                             byte[] abyte0)
+
+
+
+
+
+
+ +

+toBytes

+
+public static byte[] toBytes(long l)
+
+
+
+
+
+
+ +

+toBytes

+
+public static byte[] toBytes(long l,
+                             byte[] abyte0)
+
+
+
+
+
+
+ +

+areEqual

+
+public static boolean areEqual(byte[] abyte0,
+                               byte[] abyte1)
+
+
+
+
+
+
+ +

+append

+
+public static byte[] append(byte[] abyte0,
+                            byte[] abyte1)
+
+
+
+
+
+
+ +

+append

+
+public static byte[] append(byte[] abyte0,
+                            byte[] abyte1,
+                            byte[] abyte2)
+
+
+
+
+
+
+ +

+copy

+
+public static byte[] copy(byte[] abyte0,
+                          int i)
+
+
+
+
+
+
+ +

+copy

+
+public static byte[] copy(byte[] abyte0,
+                          int i,
+                          int j)
+
+
+
+
+
+
+ +

+merge

+
+public static void merge(byte[] abyte0,
+                         byte[] abyte1,
+                         int i,
+                         int j,
+                         int k)
+
+
+
+
+
+
+ +

+merge

+
+public static void merge(byte[] abyte0,
+                         byte[] abyte1,
+                         int i)
+
+
+
+
+
+
+ +

+merge

+
+public static void merge(byte[] abyte0,
+                         byte[] abyte1)
+
+
+
+
+
+
+ +

+merge

+
+public static void merge(byte[] abyte0,
+                         byte[] abyte1,
+                         int i,
+                         int j)
+
+
+
+
+
+
+ +

+toString

+
+public static String toString(byte[] abyte0,
+                              int i,
+                              int j)
+
+
+
+
+
+
+ +

+toString

+
+public static String toString(byte[] abyte0)
+
+
+
+
+
+
+ +

+printBytes

+
+public static void printBytes(byte[] byteArray)
+
+
+
+
+
+
+ +

+toIntLittleEndian

+
+public static int toIntLittleEndian(InputStream theInputStream)
+                             throws IOException
+
+
+ +
Throws: +
IOException
+
+
+
+ +

+toIntBigEndian

+
+public static int toIntBigEndian(InputStream theInputStream)
+                          throws IOException
+
+
+ +
Throws: +
IOException
+
+
+
+ +

+toString

+
+public static String toString(InputStream ins)
+                       throws IOException
+
+
+ +
Throws: +
IOException
+
+
+
+ +

+toStream

+
+public static void toStream(OutputStream os,
+                            int i)
+                     throws Exception
+
+
+ +
Throws: +
Exception
+
+
+
+ +

+toStream

+
+public static void toStream(OutputStream os,
+                            String s)
+                     throws Exception
+
+
+ +
Throws: +
Exception
+
+
+
+ +

+toStream

+
+public static void toStream(OutputStream os,
+                            byte[] theBytes)
+                     throws Exception
+
+
+ +
Throws: +
Exception
+
+
+
+ +

+toByteArray

+
+public static byte[] toByteArray(InputStream ins)
+                          throws IOException
+
+
+ +
Throws: +
IOException
+
+
+
+ +

+toFile

+
+public static void toFile(InputStream ins,
+                          File file)
+                   throws FileNotFoundException,
+                          IOException
+
+
+ +
Throws: +
FileNotFoundException +
IOException
+
+
+
+ +

+toStream

+
+public static void toStream(OutputStream os,
+                            File file)
+                     throws FileNotFoundException,
+                            Exception
+
+
+ +
Throws: +
FileNotFoundException +
Exception
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/Logger.html b/libraries/oscP5/reference/netP5/Logger.html new file mode 100644 index 0000000..8719681 --- /dev/null +++ b/libraries/oscP5/reference/netP5/Logger.html @@ -0,0 +1,613 @@ + + + + + + +Logger (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class Logger

+
+java.lang.Object
+  extended by netP5.Logger
+
+
+
+
public class Logger
extends Object
+ + +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static intALL + +
+           
+static intDEBUG + +
+           
+static intERROR + +
+           
+static int[]flags + +
+           
+static intINFO + +
+           
+static intOFF + +
+           
+static intON + +
+           
+static intPROCESS + +
+           
+static intWARNING + +
+           
+  + + + + + + + + + + +
+Constructor Summary
Logger() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static StringgetTime() + +
+           
+static voidprint(String theMsg) + +
+           
+static voidprintBytes(byte[] byteArray) + +
+           
+static voidprintDebug(String theLocation, + String theMsg) + +
+           
+static voidprintError(String theLocation, + String theMsg) + +
+           
+static voidprintInfo(String theLocation, + String theMsg) + +
+           
+static voidprintln(String theMsg) + +
+           
+static voidprintProcess(String theLocation, + String theMsg) + +
+           
+static voidprintWarning(String theLocation, + String theMsg) + +
+           
+static voidset(int theIndex, + int theValue) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+ON

+
+public static final int ON
+
+
+
See Also:
Constant Field Values
+
+
+ +

+OFF

+
+public static final int OFF
+
+
+
See Also:
Constant Field Values
+
+
+ +

+ERROR

+
+public static final int ERROR
+
+
+
See Also:
Constant Field Values
+
+
+ +

+WARNING

+
+public static final int WARNING
+
+
+
See Also:
Constant Field Values
+
+
+ +

+PROCESS

+
+public static final int PROCESS
+
+
+
See Also:
Constant Field Values
+
+
+ +

+INFO

+
+public static final int INFO
+
+
+
See Also:
Constant Field Values
+
+
+ +

+DEBUG

+
+public static final int DEBUG
+
+
+
See Also:
Constant Field Values
+
+
+ +

+ALL

+
+public static final int ALL
+
+
+
See Also:
Constant Field Values
+
+
+ +

+flags

+
+public static int[] flags
+
+
+
+
+ + + + + + + + +
+Constructor Detail
+ +

+Logger

+
+public Logger()
+
+
+ + + + + + + + +
+Method Detail
+ +

+set

+
+public static void set(int theIndex,
+                       int theValue)
+
+
+
+
+
+
+ +

+printError

+
+public static void printError(String theLocation,
+                              String theMsg)
+
+
+
+
+
+
+ +

+printProcess

+
+public static void printProcess(String theLocation,
+                                String theMsg)
+
+
+
+
+
+
+ +

+printWarning

+
+public static void printWarning(String theLocation,
+                                String theMsg)
+
+
+
+
+
+
+ +

+printInfo

+
+public static void printInfo(String theLocation,
+                             String theMsg)
+
+
+
+
+
+
+ +

+printDebug

+
+public static void printDebug(String theLocation,
+                              String theMsg)
+
+
+
+
+
+
+ +

+print

+
+public static void print(String theMsg)
+
+
+
+
+
+
+ +

+println

+
+public static void println(String theMsg)
+
+
+
+
+
+
+ +

+printBytes

+
+public static void printBytes(byte[] byteArray)
+
+
+
+
+
+
+ +

+getTime

+
+public static String getTime()
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/Multicast.html b/libraries/oscP5/reference/netP5/Multicast.html new file mode 100644 index 0000000..ce735bc --- /dev/null +++ b/libraries/oscP5/reference/netP5/Multicast.html @@ -0,0 +1,428 @@ + + + + + + +Multicast (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class Multicast

+
+java.lang.Object
+  extended by netP5.AbstractMulticast
+      extended by netP5.Multicast
+
+
+
All Implemented Interfaces:
Runnable, UdpPacketListener
+
+
+
+
public class Multicast
extends AbstractMulticast
implements UdpPacketListener
+ + +

+Multicast is a method of forwarding IP datagrams to a group of interested receivers. + UDP is used as the transport portocol. +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + +
+Constructor Summary
Multicast(Object theObject, + String theMulticastAddress, + int thePort) + +
+           
Multicast(Object theObject, + String theMulticastAddress, + int thePort, + int theBufferSize) + +
+          create a new instance of Multicast.
Multicast(UdpPacketListener theDatagramListener, + String theMulticastAddress, + int thePort) + +
+           
Multicast(UdpPacketListener theDatagramListener, + String theMulticastAddress, + int thePort, + int theBufferSize) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidaddListener(NetListener theListener) + +
+           
+ NetListenergetListener(int theIndex) + +
+           
+ VectorgetListeners() + +
+           
+ voidprocess(DatagramPacket thePacket, + int thePort) + +
+           
+ voidremoveListener(NetListener theListener) + +
+           
+ + + + + + + +
Methods inherited from class netP5.AbstractMulticast
close, dispose, loopback, run, send, send, setDatagramSize, setLoopback, setTimeToLive, socket, start, timeToLive
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+Multicast

+
+public Multicast(Object theObject,
+                 String theMulticastAddress,
+                 int thePort,
+                 int theBufferSize)
+
+
create a new instance of Multicast. the buffersize of the datagrams + is set to 1536 by default. +

+

+
Parameters:
theObject - Object
theMulticastAddress - String
thePort - int
theBufferSize - int
+
+
+ +

+Multicast

+
+public Multicast(Object theObject,
+                 String theMulticastAddress,
+                 int thePort)
+
+
+
+ +

+Multicast

+
+public Multicast(UdpPacketListener theDatagramListener,
+                 String theMulticastAddress,
+                 int thePort,
+                 int theBufferSize)
+
+
+
+ +

+Multicast

+
+public Multicast(UdpPacketListener theDatagramListener,
+                 String theMulticastAddress,
+                 int thePort)
+
+
+ + + + + + + + +
+Method Detail
+ +

+process

+
+public void process(DatagramPacket thePacket,
+                    int thePort)
+
+
+
Specified by:
process in interface UdpPacketListener
+
+
+
Parameters:
thePacket - DatagramPacket
thePort - int
+
+
+
+ +

+addListener

+
+public void addListener(NetListener theListener)
+
+
+
+
+
+
+
+
+
+ +

+removeListener

+
+public void removeListener(NetListener theListener)
+
+
+
+
+
+
+
+
+
+ +

+getListener

+
+public NetListener getListener(int theIndex)
+
+
+
+
+
+
+
+
+
+ +

+getListeners

+
+public Vector getListeners()
+
+
+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/NetAddress.html b/libraries/oscP5/reference/netP5/NetAddress.html new file mode 100644 index 0000000..ce4439f --- /dev/null +++ b/libraries/oscP5/reference/netP5/NetAddress.html @@ -0,0 +1,422 @@ + + + + + + +NetAddress (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class NetAddress

+
+java.lang.Object
+  extended by netP5.NetAddress
+
+
+
+
public class NetAddress
extends Object
+ + +

+NetAddress is an Object that contains an inetaddress + of an remote internet address, consisting of an + ip address and a port number. +

+ +

+

+
Author:
+
andreas schlegel
+
+
+ +

+ + + + + + + + + + + +
+Field Summary
+ Stringname + +
+           
+  + + + + + + + + + + + + + + + + +
+Constructor Summary
NetAddress(InetAddress theInetAddress, + int thePort) + +
+           
NetAddress(NetAddress theNetAddress) + +
+           
NetAddress(String theAddress, + int thePort) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ Stringaddress() + +
+          returns the remote ip address as string
+ InetAddressinetaddress() + +
+           
+ booleanisvalid() + +
+          check if the netAddress is valid.
+ intport() + +
+          returns the remote port number
+ StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+name

+
+public String name
+
+
+
+
+ + + + + + + + +
+Constructor Detail
+ +

+NetAddress

+
+public NetAddress(String theAddress,
+                  int thePort)
+
+
+
Parameters:
theAddress - String
thePort - int
+
+
+ +

+NetAddress

+
+public NetAddress(NetAddress theNetAddress)
+
+
+
+ +

+NetAddress

+
+public NetAddress(InetAddress theInetAddress,
+                  int thePort)
+
+
+
Parameters:
theInetAddress - InetAddress
thePort - int
+
+ + + + + + + + +
+Method Detail
+ +

+inetaddress

+
+public InetAddress inetaddress()
+
+
+ +
Returns:
InetAddress
+
+
+
+ +

+address

+
+public String address()
+
+
returns the remote ip address as string +

+

+ +
Returns:
String
+
+
+
+ +

+port

+
+public int port()
+
+
returns the remote port number +

+

+ +
Returns:
int
+
+
+
+ +

+isvalid

+
+public boolean isvalid()
+
+
check if the netAddress is valid. this is true if + the remote ip address was found. +

+

+ +
Returns:
boolean
+
+
+
+ +

+toString

+
+public String toString()
+
+
+
Overrides:
toString in class Object
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/NetAddressList.html b/libraries/oscP5/reference/netP5/NetAddressList.html new file mode 100644 index 0000000..c1b98bf --- /dev/null +++ b/libraries/oscP5/reference/netP5/NetAddressList.html @@ -0,0 +1,460 @@ + + + + + + +NetAddressList (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class NetAddressList

+
+java.lang.Object
+  extended by netP5.NetAddressList
+
+
+
+
public class NetAddressList
extends Object
+ + +

+NetAddressList is an arraylist of netaddresses. +

+ +

+

+
Author:
+
andreas schlegel
+
+
+ +

+ + + + + + + + + + + +
+Constructor Summary
NetAddressList() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidadd(NetAddress theNetAddress) + +
+           
+ voidadd(String theAddress, + int thePort) + +
+           
+ booleancontains(NetAddress theNetAddress) + +
+           
+ booleancontains(String theIPaddress, + int thePort) + +
+           
+ NetAddressget(int theIndex) + +
+           
+ NetAddressget(String theIPaddress, + int thePort) + +
+           
+ ArrayListlist() + +
+           
+ voidremove(NetAddress theNetAddress) + +
+           
+ voidremove(String theAddress, + int thePort) + +
+           
+ voidset(NetAddress[] theList) + +
+           
+ intsize() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+NetAddressList

+
+public NetAddressList()
+
+
+ + + + + + + + +
+Method Detail
+ +

+add

+
+public void add(NetAddress theNetAddress)
+
+
+
Parameters:
theNetAddress - NetAddress
+
+
+
+ +

+add

+
+public void add(String theAddress,
+                int thePort)
+
+
+
Parameters:
theAddress - String
thePort - int
+
+
+
+ +

+remove

+
+public void remove(String theAddress,
+                   int thePort)
+
+
+
Parameters:
theAddress - String
thePort - int
+
+
+
+ +

+remove

+
+public void remove(NetAddress theNetAddress)
+
+
+
Parameters:
theNetAddress - NetAddress
+
+
+
+ +

+get

+
+public NetAddress get(String theIPaddress,
+                      int thePort)
+
+
+
+
+
+
+ +

+contains

+
+public boolean contains(NetAddress theNetAddress)
+
+
+
Parameters:
theNetAddress - NetAddress +
Returns:
boolean
+
+
+
+ +

+contains

+
+public boolean contains(String theIPaddress,
+                        int thePort)
+
+
+
Parameters:
theIPaddress - String
thePort - int +
Returns:
boolean
+
+
+
+ +

+size

+
+public int size()
+
+
+
+
+
+
+ +

+set

+
+public void set(NetAddress[] theList)
+
+
+
Parameters:
theList - NetAddress[]
+
+
+
+ +

+list

+
+public ArrayList list()
+
+
+ +
Returns:
ArrayList
+
+
+
+ +

+get

+
+public NetAddress get(int theIndex)
+
+
+
Parameters:
theIndex - int +
Returns:
NetAddress
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/NetInfo.html b/libraries/oscP5/reference/netP5/NetInfo.html new file mode 100644 index 0000000..ec3af8e --- /dev/null +++ b/libraries/oscP5/reference/netP5/NetInfo.html @@ -0,0 +1,334 @@ + + + + + + +NetInfo (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class NetInfo

+
+java.lang.Object
+  extended by netP5.NetInfo
+
+
+
+
public class NetInfo
extends Object
+ + +

+some description +

+ +

+

+
Author:
+
andreas schlegel
+
+
+ +

+ + + + + + + + + + + +
+Constructor Summary
NetInfo() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static StringgetHostAddress() + +
+           
+static Stringlan() + +
+           
+static voidmain(String[] args) + +
+           
+static voidprint() + +
+           
+static Stringwan() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+NetInfo

+
+public NetInfo()
+
+
+ + + + + + + + +
+Method Detail
+ +

+print

+
+public static void print()
+
+
+
+
+
+
+ +

+getHostAddress

+
+public static String getHostAddress()
+
+
+
+
+
+
+ +

+lan

+
+public static String lan()
+
+
+
+
+
+
+ +

+wan

+
+public static String wan()
+
+
+
+
+
+
+ +

+main

+
+public static void main(String[] args)
+
+
+
Parameters:
args - String[]
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/NetListener.html b/libraries/oscP5/reference/netP5/NetListener.html new file mode 100644 index 0000000..990e5a8 --- /dev/null +++ b/libraries/oscP5/reference/netP5/NetListener.html @@ -0,0 +1,223 @@ + + + + + + +NetListener (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Interface NetListener

+
+
+
public interface NetListener
+ + +

+


+ +

+ + + + + + + + + + + + + + + + +
+Method Summary
+ voidnetEvent(NetMessage theNetMessage) + +
+           
+ voidnetStatus(NetStatus theStatus) + +
+           
+  +

+ + + + + + + + +
+Method Detail
+ +

+netEvent

+
+void netEvent(NetMessage theNetMessage)
+
+
+
+
+
+
+ +

+netStatus

+
+void netStatus(NetStatus theStatus)
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/NetMessage.html b/libraries/oscP5/reference/netP5/NetMessage.html new file mode 100644 index 0000000..adc6d8a --- /dev/null +++ b/libraries/oscP5/reference/netP5/NetMessage.html @@ -0,0 +1,386 @@ + + + + + + +NetMessage (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class NetMessage

+
+java.lang.Object
+  extended by netP5.NetMessage
+
+
+
+
public class NetMessage
extends Object
+ + +

+

+
Author:
+
andreas schlegel
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ Stringaddress() + +
+           
+ byte[]getData() + +
+          get the data of the message as bytes.
+ DatagramPacketgetDatagramPacket() + +
+           
+ StringgetString() + +
+          get the data the message as string.
+ TcpPacketgetTcpPacket() + +
+           
+ InetAddressinetAddress() + +
+           
+ intport() + +
+          get the port the net message was received at.
+ intprotocol() + +
+          get the protocol type the message was sent over.
+ TcpClienttcpConnection() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+getTcpPacket

+
+public TcpPacket getTcpPacket()
+
+
+
+
+
+
+ +

+getDatagramPacket

+
+public DatagramPacket getDatagramPacket()
+
+
+
+
+
+
+ +

+getData

+
+public byte[] getData()
+
+
get the data of the message as bytes. +

+

+ +
Returns:
+
+
+
+ +

+getString

+
+public String getString()
+
+
get the data the message as string. +

+

+ +
Returns:
+
+
+
+ +

+protocol

+
+public int protocol()
+
+
get the protocol type the message was sent over. + NetP5.TCP or NetP5.UDP are possible. +

+

+ +
Returns:
+
+
+
+ +

+port

+
+public int port()
+
+
get the port the net message was received at. +

+

+ +
Returns:
+
+
+
+ +

+tcpConnection

+
+public TcpClient tcpConnection()
+
+
+
+
+
+
+ +

+address

+
+public String address()
+
+
+
+
+
+
+ +

+inetAddress

+
+public InetAddress inetAddress()
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/NetP5.html b/libraries/oscP5/reference/netP5/NetP5.html new file mode 100644 index 0000000..86219fa --- /dev/null +++ b/libraries/oscP5/reference/netP5/NetP5.html @@ -0,0 +1,274 @@ + + + + + + +NetP5 (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Interface NetP5

+
+
+
public interface NetP5
+ + +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static booleanDEBUG + +
+           
+static intMULTICAST + +
+           
+static intTCP + +
+           
+static intUDP + +
+           
+static StringVERSION + +
+           
+  +

+ + + + + + + + +
+Field Detail
+ +

+VERSION

+
+static final String VERSION
+
+
+
See Also:
Constant Field Values
+
+
+ +

+DEBUG

+
+static final boolean DEBUG
+
+
+
See Also:
Constant Field Values
+
+
+ +

+UDP

+
+static final int UDP
+
+
+
See Also:
Constant Field Values
+
+
+ +

+MULTICAST

+
+static final int MULTICAST
+
+
+
See Also:
Constant Field Values
+
+
+ +

+TCP

+
+static final int TCP
+
+
+
See Also:
Constant Field Values
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/NetStatus.html b/libraries/oscP5/reference/netP5/NetStatus.html new file mode 100644 index 0000000..7293687 --- /dev/null +++ b/libraries/oscP5/reference/netP5/NetStatus.html @@ -0,0 +1,434 @@ + + + + + + +NetStatus (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class NetStatus

+
+java.lang.Object
+  extended by netP5.NetStatus
+
+
+
+
public class NetStatus
extends Object
+ + +

+

+
Author:
+
andreas schlegel
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static intCLIENT_CLOSED + +
+           
+static intCONNECTION_CLOSED + +
+           
+static intCONNECTION_FAILED + +
+           
+static intCONNECTION_REFUSED + +
+           
+static intCONNECTION_TERMINATED + +
+           
+static intDEFAULT + +
+           
+static intERROR + +
+           
+static intSEND_FAILED + +
+           
+static intSERVER_CLOSED + +
+           
+  + + + + + + + + + + +
+Constructor Summary
NetStatus(int theIndex) + +
+           
+  + + + + + + + + + + + +
+Method Summary
+ intid() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+ERROR

+
+public static int ERROR
+
+
+
+
+
+ +

+DEFAULT

+
+public static int DEFAULT
+
+
+
+
+
+ +

+CONNECTION_CLOSED

+
+public static int CONNECTION_CLOSED
+
+
+
+
+
+ +

+CONNECTION_REFUSED

+
+public static int CONNECTION_REFUSED
+
+
+
+
+
+ +

+CONNECTION_TERMINATED

+
+public static int CONNECTION_TERMINATED
+
+
+
+
+
+ +

+CONNECTION_FAILED

+
+public static int CONNECTION_FAILED
+
+
+
+
+
+ +

+SERVER_CLOSED

+
+public static int SERVER_CLOSED
+
+
+
+
+
+ +

+CLIENT_CLOSED

+
+public static int CLIENT_CLOSED
+
+
+
+
+
+ +

+SEND_FAILED

+
+public static int SEND_FAILED
+
+
+
+
+ + + + + + + + +
+Constructor Detail
+ +

+NetStatus

+
+public NetStatus(int theIndex)
+
+
+ + + + + + + + +
+Method Detail
+ +

+id

+
+public int id()
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/StringUtils.html b/libraries/oscP5/reference/netP5/StringUtils.html new file mode 100644 index 0000000..5357371 --- /dev/null +++ b/libraries/oscP5/reference/netP5/StringUtils.html @@ -0,0 +1,1008 @@ + + + + + + +StringUtils (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class StringUtils

+
+java.lang.Object
+  extended by netP5.StringUtils
+
+
+
+
public class StringUtils
extends Object
+ + +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+static StringarrayToString(String[] theArray) + +
+           
+static StringarrayToString(String[] theArray, + int theStart, + int theEnd) + +
+           
+static StringcenterJustify(String source, + int length) + +
+          Creates a string of the given width with the given string left justified + (padded by an appropriate number of spaces in front and after it).
+static Stringduplicate(String source, + int copies) + +
+          Returns a String with the source String copied the specified number of + times.
+static String[]explode(String source) + +
+          Splits a string into an array with a space as delimiter.
+static Vectorexplode(String[] source, + int[] lengths) + +
+          Splits every String in an array at the specified lengths.
+static String[]explode(String source, + int[] lengths) + +
+          Splits a string at the specified lengths and returns an array of Strings.
+static String[]explode(String s, + String delimiter) + +
+          Splits a string into an array with the specified delimiter.
+static floatgetFloat(String theString) + +
+           
+static intgetInt(String theString) + +
+           
+static StringgetStackTrace(Throwable t) + +
+          Prints the stacktrace to a buffer and returns the buffer as a String.
+static Stringimplode(Object[] elements) + +
+          Combines an array to a string, using a comma and a space as delimiter.
+static Stringimplode(Object[] elements, + String delimiter) + +
+          Combines an array to a string, using the specified delimiter.
+static booleanisEmpty(String s) + +
+          Checks if a String is empty or null.
+static Stringleft(String source, + String searchFor) + +
+          Returns the substring to the left of the specified substring in the + specified String, starting from the left.
+static StringleftBack(String source, + String searchFor) + +
+          Returns the substring to the left of the specified substring in the + specified String, starting from the right.
+static StringleftJustify(String source, + int length) + +
+          Creates a string of the given width with the given string left justified + (followed by an appropriate number of spaces).
+static Stringmiddle(String source, + int startIndex, + int length) + +
+          Returns a substring of a String, starting from specified index and with + specified length.
+static Stringmiddle(String source, + String start, + String end) + +
+          Returns the substring between two substrings.
+static Stringremove(String source, + char searchFor) + +
+          Removes all instances of a character in a String.
+static Stringremove(String source, + String searchFor) + +
+          Removes all instances of a substring in a String.
+static Stringremove(String source, + String[] searchFor) + +
+          Removes all instances of substrings in a String.
+static StringremoveDuplicates(String source, + String searchFor) + +
+          Removes duplicates of a substring in a String.
+static Stringreplace(String source, + String[] searchFor, + String replaceWith) + +
+          Replaces several substrings in a string.
+static Stringreplace(String source, + String searchFor, + String replaceWith) + +
+          Replaces substrings in a string.
+static Stringright(String source, + String searchFor) + +
+          Returns the substring to the right of the specified substring in the + specified String, starting from the left.
+static StringrightBack(String source, + String searchFor) + +
+          Returns the substring to the right of the specified substring in the + specified String, starting from the right.
+static StringrightJustify(String source, + int length) + +
+          Creates a string of the given width with the given string right justified + (with an appropriate number of spaces before it).
+static String[]slice(int theNum, + String[] theStringArray) + +
+           
+static Stringspaces(int length) + +
+          Returns a String with the specified number of spaces.
+static charswitchCase(char source) + +
+          Switches the case of the supplied character.
+static StringswitchCase(String source) + +
+          Switches the case of the supplied String.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Method Detail
+ +

+right

+
+public static String right(String source,
+                           String searchFor)
+
+
Returns the substring to the right of the specified substring in the + specified String, starting from the left. +

+

+
Parameters:
source - the source String to search.
searchFor - the substring to search for in source. +
Returns:
the substring that is to the right of searchFor in source.
+
+
+
+ +

+rightBack

+
+public static String rightBack(String source,
+                               String searchFor)
+
+
Returns the substring to the right of the specified substring in the + specified String, starting from the right. +

+

+
Parameters:
source - the source String to search.
searchFor - the substring to search for in source. +
Returns:
the substring that is to the right of searchFor in source, + starting from the right.
+
+
+
+ +

+left

+
+public static String left(String source,
+                          String searchFor)
+
+
Returns the substring to the left of the specified substring in the + specified String, starting from the left. +

+

+
Parameters:
source - the source String to search.
searchFor - the substring to search for in source. +
Returns:
the substring that is to the left of searchFor in source.
+
+
+
+ +

+leftBack

+
+public static String leftBack(String source,
+                              String searchFor)
+
+
Returns the substring to the left of the specified substring in the + specified String, starting from the right. +

+

+
Parameters:
source - the source String to search.
searchFor - the substring to search for in source. +
Returns:
the substring that is to the left of searchFor in source, + starting from the right.
+
+
+
+ +

+middle

+
+public static String middle(String source,
+                            String start,
+                            String end)
+
+
Returns the substring between two substrings. I.e. + StringUtils.middle("This i a big challenge", "a", "challenge") returns " + big ". +

+

+
Parameters:
source - the String to search.
start - the String to the left to search for, from the left.
end - the String to the right to search for, from the right.
+
+
+
+ +

+middle

+
+public static String middle(String source,
+                            int startIndex,
+                            int length)
+
+
Returns a substring of a String, starting from specified index and with + specified length. I. e. StringUtils.middle("This is a big challenge", 5, + 6) returns " is a " +

+

+
Parameters:
source - the String to get a substring from.
startIndex - the index in the source String to get the substring from.
length - the length of the substring to return.
+
+
+
+ +

+replace

+
+public static String replace(String source,
+                             String searchFor,
+                             String replaceWith)
+
+
Replaces substrings in a string. +

+

+
Parameters:
source - the source String to replace substrings in.
searchFor - the string to search for.
replaceWith - the string to replace all found searchFor-substrings with.
+
+
+
+ +

+replace

+
+public static String replace(String source,
+                             String[] searchFor,
+                             String replaceWith)
+
+
Replaces several substrings in a string. +

+

+
Parameters:
source - the source String to replace substrings in.
searchFor - the substrings to search for.
replaceWith - what to replace every searchFor with,
+
+
+
+ +

+explode

+
+public static Vector explode(String[] source,
+                             int[] lengths)
+
+
Splits every String in an array at the specified lengths. + + Example:
+ String source[] = { "123a123b123c123d", "Bla1bla2bla3bla4bla5bla6bla7" };
+ int[] lengths = { 3, 1, 3, 1 };
+ Vector result = StringUtils.explode(source, lengths);
+ Object element = null;
+ String[] rowElements = null;
+ Enumeration enum = result.elements();
+ while (enum.hasMoreElements()) {
+        element = enum.nextElement();
+        if (element instanceof String[]) {
+                rowElements = (String[]) element;
+                for (int i = 0; i < rowElements.length; i++) {
+                        System.out.println(rowElements[i]);
+                }
+        }
+ }
+ 
The result that will be output: 123 a 123 b + + Bla 1 bla 2 +

+

+ +
Returns:
a Vector containing String arrays (the rows).
+
+
+
+ +

+explode

+
+public static String[] explode(String source,
+                               int[] lengths)
+
+
Splits a string at the specified lengths and returns an array of Strings. +

+

+
Parameters:
source - the String to split. +
Returns:
an array of Strings with the same number of elements as the + number of elements in the lengths argument. The length of each + String element is specified by the correspondent lengths array + element. +
Throws: +
IndexOutOfBoundsException - if any of the length´s are invalid.
+
+
+
+ +

+explode

+
+public static String[] explode(String source)
+
+
Splits a string into an array with a space as delimiter. +

+

+
Parameters:
source - the source String to explode. +
Returns:
an array of strings that are made out of splitting the string at + the spaces.
+
+
+
+ +

+explode

+
+public static String[] explode(String s,
+                               String delimiter)
+
+
Splits a string into an array with the specified delimiter. Original code + Copyright (C) 2001,2002 Stephen Ostermiller + http://ostermiller.org/utils/StringHelper.java.html + +

+ This method is meant to be similar to the split function in other + programming languages but it does not use regular expressions. Rather the + String is split on a single String literal. It is equivalent to the +

+

+
Parameters:
s - the String to explode.
delimiter - the delimiter where to split the string. +
Returns:
an array of strings that are made out of splitting the string at + the specified delimiter. +
Throws: +
NullPointerException - if s is null.
+
+
+
+ +

+slice

+
+public static String[] slice(int theNum,
+                             String[] theStringArray)
+
+
+
+
+
+
+ +

+implode

+
+public static String implode(Object[] elements,
+                             String delimiter)
+
+
Combines an array to a string, using the specified delimiter. +

+

+
Parameters:
elements - the array to combine to a single string.
delimiter - the delimiter to put between the combined elements. +
Returns:
the array combined to a string.
+
+
+
+ +

+implode

+
+public static String implode(Object[] elements)
+
+
Combines an array to a string, using a comma and a space as delimiter. +

+

+
Parameters:
elements - the array to combine to a single string. +
Returns:
the array combined to a string.
+
+
+
+ +

+remove

+
+public static String remove(String source,
+                            char searchFor)
+
+
Removes all instances of a character in a String. +

+

+
Parameters:
source - the String to remove substring in.
searchFor - the character to remove. +
Returns:
the replaced String.
+
+
+
+ +

+remove

+
+public static String remove(String source,
+                            String searchFor)
+
+
Removes all instances of a substring in a String. +

+

+
Parameters:
source - the String to remove substring in.
searchFor - the substring to remove. +
Returns:
the replaced String.
+
+
+
+ +

+remove

+
+public static String remove(String source,
+                            String[] searchFor)
+
+
Removes all instances of substrings in a String. +

+

+
Parameters:
source - the String to remove substrings in.
searchFor - an array of substrings to remove from the source String. +
Returns:
the replaced String.
+
+
+
+ +

+removeDuplicates

+
+public static String removeDuplicates(String source,
+                                      String searchFor)
+
+
Removes duplicates of a substring in a String. Case sensitive. +

+

+
Parameters:
source - the String to remove duplicates in.
searchFor - the substring that can only occur one at a time, several can + exist in the source though.
+
+
+
+ +

+getStackTrace

+
+public static String getStackTrace(Throwable t)
+                            throws IOException
+
+
Prints the stacktrace to a buffer and returns the buffer as a String. +

+

+
Parameters:
t - the Throwable you wnat to generate a stacktrace for. +
Returns:
the stacktrace of the supplied Throwable. +
Throws: +
IOException
+
+
+
+ +

+isEmpty

+
+public static boolean isEmpty(String s)
+
+
Checks if a String is empty or null. +

+

+
Parameters:
s - the String to test if it is empty or null. +
Returns:
true if the String is null or empty ("").
+
+
+
+ +

+leftJustify

+
+public static String leftJustify(String source,
+                                 int length)
+
+
Creates a string of the given width with the given string left justified + (followed by an appropriate number of spaces). +

+

+
Parameters:
source - the String to justify
length - the length of the resulting String +
Returns:
the source String padded with spaces to fill up the length. If + the source string is longer than the length argument, the source + String is returned.
+
+
+
+ +

+rightJustify

+
+public static String rightJustify(String source,
+                                  int length)
+
+
Creates a string of the given width with the given string right justified + (with an appropriate number of spaces before it). +

+

+
Parameters:
source - the String to justify
length - the length of the resulting String +
Returns:
the source String padded with spaces to fill up the length. If + the source string is longer than the length argument, the source + String is returned.
+
+
+
+ +

+centerJustify

+
+public static String centerJustify(String source,
+                                   int length)
+
+
Creates a string of the given width with the given string left justified + (padded by an appropriate number of spaces in front and after it). +

+

+
Parameters:
source - the String to justify
length - the length of the resulting String +
Returns:
the source String padded with spaces to fill up the length. If + the source string is longer than the length argument, the source + String is returned.
+
+
+
+ +

+spaces

+
+public static String spaces(int length)
+
+
Returns a String with the specified number of spaces. +

+

+
Parameters:
length - the number of spaces to return. +
Returns:
a String consisting of the specified number of spaces.
+
+
+
+ +

+duplicate

+
+public static String duplicate(String source,
+                               int copies)
+
+
Returns a String with the source String copied the specified number of + times. +

+

+
Parameters:
source - the source String to copy.
length - the number of copies of source to return. +
Returns:
a String consisting of the specified source String copied the + specified number of times.
+
+
+
+ +

+switchCase

+
+public static String switchCase(String source)
+
+
Switches the case of the supplied String. Any lower case characters will + be uppercase and vice versa. +

+

+
Parameters:
source - the String to switch case of. +
Returns:
the supplied String with switched case.
+
+
+
+ +

+switchCase

+
+public static char switchCase(char source)
+
+
Switches the case of the supplied character. A lower case character will + be uppercase and vice versa. +

+

+
Parameters:
source - the character to switch case of. +
Returns:
the supplied character with switched case.
+
+
+
+ +

+getInt

+
+public static int getInt(String theString)
+
+
+
+
+
+
+ +

+getFloat

+
+public static float getFloat(String theString)
+
+
+
+
+
+
+ +

+arrayToString

+
+public static String arrayToString(String[] theArray)
+
+
+
+
+
+
+ +

+arrayToString

+
+public static String arrayToString(String[] theArray,
+                                   int theStart,
+                                   int theEnd)
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/TcpClient.html b/libraries/oscP5/reference/netP5/TcpClient.html new file mode 100644 index 0000000..0781ef2 --- /dev/null +++ b/libraries/oscP5/reference/netP5/TcpClient.html @@ -0,0 +1,473 @@ + + + + + + +TcpClient (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class TcpClient

+
+java.lang.Object
+  extended by netP5.AbstractTcpClient
+      extended by netP5.TcpClient
+
+
+
All Implemented Interfaces:
Runnable
+
+
+
+
public class TcpClient
extends AbstractTcpClient
+ + +

+

+
Author:
+
andreas schlegel
+
+
+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from class netP5.AbstractTcpClient
MODE_NEWLINE, MODE_READLINE, MODE_STREAM, MODE_TERMINATED
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Constructor Summary
TcpClient(AbstractTcpServer theTcpServer, + Socket theSocket, + TcpPacketListener theTcpPacketListener, + int theServerPort, + int theMode) + +
+           
TcpClient(NetAddress theNetAddress) + +
+           
TcpClient(Object theObject, + NetAddress theNetAddress) + +
+           
TcpClient(Object theObject, + String theAddress, + int thePort) + +
+           
TcpClient(Object theObject, + String theAddress, + int thePort, + int theMode) + +
+           
TcpClient(String theAddress, + int thePort) + +
+           
TcpClient(TcpPacketListener theListener, + String theServerAddress, + int theServerPort, + int theMode) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidhandleInput() + +
+           
+ voidhandleStatus(int theIndex) + +
+           
+ Stringname() + +
+           
+ voidsetName(String theName) + +
+           
+ + + + + + + +
Methods inherited from class netP5.AbstractTcpClient
dispose, equals, equals, getString, getStringBuffer, listener, mode, netaddress, netAddress, reconnect, run, send, send, send, serverport, setTerminator, socket
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+TcpClient

+
+public TcpClient(Object theObject,
+                 String theAddress,
+                 int thePort)
+
+
+
Parameters:
theAddress - String
thePort - int
+
+
+ +

+TcpClient

+
+public TcpClient(Object theObject,
+                 String theAddress,
+                 int thePort,
+                 int theMode)
+
+
+
Parameters:
theObject - Object
theAddress - String
thePort - int
theMode - int
+
+
+ +

+TcpClient

+
+public TcpClient(TcpPacketListener theListener,
+                 String theServerAddress,
+                 int theServerPort,
+                 int theMode)
+
+
+
Parameters:
theListener - TcpPacketListener
theServerAddress - String
theServerPort - int
theMode - int
+
+
+ +

+TcpClient

+
+public TcpClient(Object theObject,
+                 NetAddress theNetAddress)
+
+
+
Parameters:
theNetAddress - NetAddress
+
+
+ +

+TcpClient

+
+public TcpClient(NetAddress theNetAddress)
+
+
+
Parameters:
theNetAddress - NetAddress
+
+
+ +

+TcpClient

+
+public TcpClient(String theAddress,
+                 int thePort)
+
+
+
Parameters:
theAddress - String
thePort - int
+
+
+ +

+TcpClient

+
+public TcpClient(AbstractTcpServer theTcpServer,
+                 Socket theSocket,
+                 TcpPacketListener theTcpPacketListener,
+                 int theServerPort,
+                 int theMode)
+
+
+ + + + + + + + +
+Method Detail
+ +

+handleStatus

+
+public void handleStatus(int theIndex)
+
+
+
Specified by:
handleStatus in class AbstractTcpClient
+
+
+
Parameters:
theIndex - int
+
+
+
+ +

+handleInput

+
+public void handleInput()
+
+
+
Specified by:
handleInput in class AbstractTcpClient
+
+
+
+
+
+
+ +

+name

+
+public String name()
+
+
+ +
Returns:
String
+
+
+
+ +

+setName

+
+public void setName(String theName)
+
+
+
Parameters:
theName - String
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/TcpPacket.html b/libraries/oscP5/reference/netP5/TcpPacket.html new file mode 100644 index 0000000..bab40ac --- /dev/null +++ b/libraries/oscP5/reference/netP5/TcpPacket.html @@ -0,0 +1,311 @@ + + + + + + +TcpPacket (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class TcpPacket

+
+java.lang.Object
+  extended by netP5.TcpPacket
+
+
+
+
public class TcpPacket
extends Object
+ + +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
TcpPacket(TcpClient theTcpClient, + StringBuffer theBuffer, + byte[] theBytes) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ byte[]getData() + +
+           
+ StringgetString() + +
+           
+ StringBuffergetStringBuffer() + +
+           
+ TcpClientgetTcpConnection() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+TcpPacket

+
+public TcpPacket(TcpClient theTcpClient,
+                 StringBuffer theBuffer,
+                 byte[] theBytes)
+
+
+ + + + + + + + +
+Method Detail
+ +

+getTcpConnection

+
+public TcpClient getTcpConnection()
+
+
+
+
+
+
+ +

+getString

+
+public String getString()
+
+
+
+
+
+
+ +

+getStringBuffer

+
+public StringBuffer getStringBuffer()
+
+
+
+
+
+
+ +

+getData

+
+public byte[] getData()
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/TcpPacketListener.html b/libraries/oscP5/reference/netP5/TcpPacketListener.html new file mode 100644 index 0000000..04cc6d2 --- /dev/null +++ b/libraries/oscP5/reference/netP5/TcpPacketListener.html @@ -0,0 +1,247 @@ + + + + + + +TcpPacketListener (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Interface TcpPacketListener

+
+
All Known Implementing Classes:
AbstractTcpServer, OscNetManager, OscP5, TcpServer
+
+
+
+
public interface TcpPacketListener
+ + +

+


+ +

+ + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidprocess(TcpPacket theTcpPacket, + int thePort) + +
+           
+ voidremove(AbstractTcpClient theClient) + +
+           
+ voidstatus(int theStatus) + +
+           
+  +

+ + + + + + + + +
+Method Detail
+ +

+process

+
+void process(TcpPacket theTcpPacket,
+             int thePort)
+
+
+
+
+
+
+ +

+status

+
+void status(int theStatus)
+
+
+
+
+
+
+ +

+remove

+
+void remove(AbstractTcpClient theClient)
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/TcpServer.html b/libraries/oscP5/reference/netP5/TcpServer.html new file mode 100644 index 0000000..a79b380 --- /dev/null +++ b/libraries/oscP5/reference/netP5/TcpServer.html @@ -0,0 +1,463 @@ + + + + + + +TcpServer (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class TcpServer

+
+java.lang.Object
+  extended by netP5.AbstractTcpServer
+      extended by netP5.TcpServer
+
+
+
All Implemented Interfaces:
Runnable, TcpPacketListener
+
+
+
+
public class TcpServer
extends AbstractTcpServer
+ + +

+

+
Author:
+
andreas schlegel
+
+
+ +

+ + + + + + + +
+Field Summary
+ + + + + + + +
Fields inherited from class netP5.AbstractTcpServer
MODE_NEWLINE, MODE_READLINE, MODE_STREAM, MODE_TERMINATED
+  + + + + + + + + + + + + + + + + + + + + + + +
+Constructor Summary
TcpServer(int thePort) + +
+           
TcpServer(int thePort, + int theMode) + +
+           
TcpServer(Object theObject, + int thePort) + +
+           
TcpServer(Object theObject, + int thePort, + int theMode) + +
+           
TcpServer(TcpPacketListener theTcpPacketListener, + int thePort, + int theMode) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidaddListener(NetListener theListener) + +
+           
+ NetListenergetListener(int theIndex) + +
+           
+ VectorgetListeners() + +
+           
+ voidhandleInput(TcpPacket thePacket, + int thePort) + +
+           
+ voidremoveListener(NetListener theListener) + +
+           
+ voidstatus(int theIndex) + +
+           
+ + + + + + + +
Methods inherited from class netP5.AbstractTcpServer
ban, dispose, getClient, getClients, process, remove, run, send, send, size, socket, unBan
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+TcpServer

+
+public TcpServer(int thePort)
+
+
+
Parameters:
thePort - int
+
+
+ +

+TcpServer

+
+public TcpServer(Object theObject,
+                 int thePort)
+
+
+
Parameters:
theObject - Object
thePort - int
+
+
+ +

+TcpServer

+
+public TcpServer(Object theObject,
+                 int thePort,
+                 int theMode)
+
+
+
Parameters:
theObject - Object
thePort - int
theMode - int
+
+
+ +

+TcpServer

+
+public TcpServer(int thePort,
+                 int theMode)
+
+
+
Parameters:
thePort - int
theMode - int
+
+
+ +

+TcpServer

+
+public TcpServer(TcpPacketListener theTcpPacketListener,
+                 int thePort,
+                 int theMode)
+
+
+
Parameters:
theTcpPacketListener - TcpPacketListener
thePort - int
theMode - int
+
+ + + + + + + + +
+Method Detail
+ +

+handleInput

+
+public void handleInput(TcpPacket thePacket,
+                        int thePort)
+
+
+
Specified by:
handleInput in class AbstractTcpServer
+
+
+
Parameters:
thePacket - TcpPacket
thePort - int
+
+
+
+ +

+status

+
+public void status(int theIndex)
+
+
+
Parameters:
theIndex - int
+
+
+
+ +

+addListener

+
+public void addListener(NetListener theListener)
+
+
+
+
+
+
+ +

+removeListener

+
+public void removeListener(NetListener theListener)
+
+
+
+
+
+
+ +

+getListener

+
+public NetListener getListener(int theIndex)
+
+
+
+
+
+
+ +

+getListeners

+
+public Vector getListeners()
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/UdpClient.html b/libraries/oscP5/reference/netP5/UdpClient.html new file mode 100644 index 0000000..7edd272 --- /dev/null +++ b/libraries/oscP5/reference/netP5/UdpClient.html @@ -0,0 +1,266 @@ + + + + + + +UdpClient (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class UdpClient

+
+java.lang.Object
+  extended by netP5.AbstractUdpClient
+      extended by netP5.UdpClient
+
+
+
+
public class UdpClient
extends AbstractUdpClient
+ + +

+

+
Author:
+
andreas schlegel
+
+
+ +

+ + + + + + + + + + + + + + + + + +
+Constructor Summary
UdpClient() + +
+           
UdpClient(NetAddress theNetAddress) + +
+           
UdpClient(String theAddr, + int thePort) + +
+           
+  + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class netP5.AbstractUdpClient
send, send, send, send, send, send, socket
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+UdpClient

+
+public UdpClient()
+
+
+
+ +

+UdpClient

+
+public UdpClient(String theAddr,
+                 int thePort)
+
+
+
+ +

+UdpClient

+
+public UdpClient(NetAddress theNetAddress)
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/UdpPacketListener.html b/libraries/oscP5/reference/netP5/UdpPacketListener.html new file mode 100644 index 0000000..9a70362 --- /dev/null +++ b/libraries/oscP5/reference/netP5/UdpPacketListener.html @@ -0,0 +1,213 @@ + + + + + + +UdpPacketListener (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Interface UdpPacketListener

+
+
All Known Implementing Classes:
Multicast, OscNetManager, OscP5, UdpServer
+
+
+
+
public interface UdpPacketListener
+ + +

+

+
Author:
+
andreas schlegel
+
+
+ +

+ + + + + + + + + + + + +
+Method Summary
+ voidprocess(DatagramPacket theDatagramPacket, + int thePort) + +
+           
+  +

+ + + + + + + + +
+Method Detail
+ +

+process

+
+void process(DatagramPacket theDatagramPacket,
+             int thePort)
+
+
+
Parameters:
theDatagramPacket - DatagramPacket
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/UdpServer.html b/libraries/oscP5/reference/netP5/UdpServer.html new file mode 100644 index 0000000..700e9b7 --- /dev/null +++ b/libraries/oscP5/reference/netP5/UdpServer.html @@ -0,0 +1,411 @@ + + + + + + +UdpServer (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +netP5 +
+Class UdpServer

+
+java.lang.Object
+  extended by netP5.AbstractUdpServer
+      extended by netP5.UdpServer
+
+
+
All Implemented Interfaces:
Runnable, UdpPacketListener
+
+
+
+
public class UdpServer
extends AbstractUdpServer
implements UdpPacketListener
+ + +

+

+
Author:
+
andreas schlegel
+
+
+ +

+ + + + + + + + + + + + + + + + + +
+Constructor Summary
UdpServer(Object theObject, + int thePort) + +
+           
UdpServer(Object theObject, + int thePort, + int theBufferSize) + +
+          new UDP server.
UdpServer(UdpPacketListener theListener, + int thePort, + int theBufferSize) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidaddListener(NetListener theListener) + +
+          add a listener to the udp server.
+ NetListenergetListener(int theIndex) + +
+           
+ VectorgetListeners() + +
+           
+ voidprocess(DatagramPacket thePacket, + int thePort) + +
+           
+ voidremoveListener(NetListener theListener) + +
+           
+ + + + + + + +
Methods inherited from class netP5.AbstractUdpServer
dispose, run, send, send, send, send, socket, start
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+UdpServer

+
+public UdpServer(Object theObject,
+                 int thePort,
+                 int theBufferSize)
+
+
new UDP server. + by default the buffersize of a udp packet is 1536 bytes. you can set + your own individual buffersize with the third parameter int in the constructor. +

+

+
Parameters:
theObject - Object
thePort - int
theBufferSize - int
+
+
+ +

+UdpServer

+
+public UdpServer(Object theObject,
+                 int thePort)
+
+
+
+ +

+UdpServer

+
+public UdpServer(UdpPacketListener theListener,
+                 int thePort,
+                 int theBufferSize)
+
+
+
Parameters:
theListener -
thePort -
theBufferSize -
+
+ + + + + + + + +
+Method Detail
+ +

+process

+
+public void process(DatagramPacket thePacket,
+                    int thePort)
+
+
+
Specified by:
process in interface UdpPacketListener
+
+
+
Parameters:
thePacket - DatagramPacket
thePort - int
+
+
+
+ +

+addListener

+
+public void addListener(NetListener theListener)
+
+
add a listener to the udp server. each incoming packet will be forwarded + to the listener. +

+

+
+
+
+
Parameters:
theListener -
+
+
+
+ +

+removeListener

+
+public void removeListener(NetListener theListener)
+
+
+
+
+
+
Parameters:
theListener -
+
+
+
+ +

+getListener

+
+public NetListener getListener(int theIndex)
+
+
+
+
+
+
Parameters:
theIndex - +
Returns:
+
+
+
+ +

+getListeners

+
+public Vector getListeners()
+
+
+
+
+
+ +
Returns:
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/package-frame.html b/libraries/oscP5/reference/netP5/package-frame.html new file mode 100644 index 0000000..49c374e --- /dev/null +++ b/libraries/oscP5/reference/netP5/package-frame.html @@ -0,0 +1,85 @@ + + + + + + +netP5 (Javadocs: oscP5) + + + + + + + + + + + +netP5 + + + + +
+Interfaces  + +
+NetListener +
+NetP5 +
+TcpPacketListener +
+UdpPacketListener
+ + + + + + +
+Classes  + +
+AbstractMulticast +
+AbstractTcpClient +
+AbstractTcpServer +
+AbstractUdpClient +
+AbstractUdpServer +
+Bytes +
+Logger +
+Multicast +
+NetAddress +
+NetAddressList +
+NetInfo +
+NetMessage +
+NetStatus +
+StringUtils +
+TcpClient +
+TcpPacket +
+TcpServer +
+UdpClient +
+UdpServer
+ + + + diff --git a/libraries/oscP5/reference/netP5/package-summary.html b/libraries/oscP5/reference/netP5/package-summary.html new file mode 100644 index 0000000..186e368 --- /dev/null +++ b/libraries/oscP5/reference/netP5/package-summary.html @@ -0,0 +1,255 @@ + + + + + + +netP5 (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package netP5 +

+ + + + + + + + + + + + + + + + + + + + + +
+Interface Summary
NetListener 
NetP5 
TcpPacketListener 
UdpPacketListener 
+  + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class Summary
AbstractMulticast 
AbstractTcpClient 
AbstractTcpServer 
AbstractUdpClient 
AbstractUdpServer 
Bytes 
Logger 
MulticastMulticast is a method of forwarding IP datagrams to a group of interested receivers.
NetAddressNetAddress is an Object that contains an inetaddress + of an remote internet address, consisting of an + ip address and a port number.
NetAddressListNetAddressList is an arraylist of netaddresses.
NetInfosome description
NetMessage 
NetStatus 
StringUtils 
TcpClient 
TcpPacket 
TcpServer 
UdpClient 
UdpServer 
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/netP5/package-tree.html b/libraries/oscP5/reference/netP5/package-tree.html new file mode 100644 index 0000000..98492d1 --- /dev/null +++ b/libraries/oscP5/reference/netP5/package-tree.html @@ -0,0 +1,172 @@ + + + + + + +netP5 Class Hierarchy (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package netP5 +

+
+
+
Package Hierarchies:
All Packages
+
+

+Class Hierarchy +

+ +

+Interface Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/OscArgument.html b/libraries/oscP5/reference/oscP5/OscArgument.html new file mode 100644 index 0000000..9bcf998 --- /dev/null +++ b/libraries/oscP5/reference/oscP5/OscArgument.html @@ -0,0 +1,1160 @@ + + + + + + +OscArgument (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +oscP5 +
+Class OscArgument

+
+java.lang.Object
+  extended by oscP5.OscArgument
+
+
+
+
public class OscArgument
extends Object
+ + +

+an osc argument contains one value of values from a received osc message. + you can convert the value into the required format, e.g. from Object to int + theOscMessage.get(0).intValue(); +

+ +

+

+ +
+Example
/**
+ * oscP5oscArgument by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an alternative way to parse messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+  /* send an OSC message to this sketch */
+  oscP5.send("/test",new Object[] {new Integer("1"), new Float(2.0),"test string."}, myRemoteLocation);
+  
+}
+
+void draw() {
+  background(0);  
+}
+
+void oscEvent(OscMessage theOscMessage) {
+  /* check if theOscMessage has the address pattern we are looking for. */  
+  if(theOscMessage.checkAddrPattern("/test")==true) {
+    /* check if the typetag is the right one. */
+    if(theOscMessage.checkTypetag("ifs")) {
+      /* parse theOscMessage and extract the values from the osc message arguments. */
+      int firstValue = theOscMessage.get(0).intValue();  // get the first osc argument
+      float secondValue = theOscMessage.get(1).floatValue(); // get the second osc argument
+      String thirdValue = theOscMessage.get(2).stringValue(); // get the third osc argument
+      print("### received an osc message /test with typetag ifs.");
+      println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+      return;
+    }
+  }
+  println("### received an osc message. with address pattern "+
+          theOscMessage.addrPattern()+" typetag "+ theOscMessage.typetag());
+}
+
+
+ +

+ + + + + + + + + + + +
+Constructor Summary
OscArgument() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ byte[]blobValue() + +
+          get the byte array (blob) of the osc argument.
+ booleanbooleanValue() + +
+          get the boolean value of the osc argument.
+ byte[]bytesValue() + +
+          get the byte array of the osc argument.
+ charcharValue() + +
+          get the char value of the osc argument.
+ doubledoubleValue() + +
+          get the double value of the osc argument.
+ floatfloatValue() + +
+          get the float value of the osc argument.
+ intintValue() + +
+          get the int value of the osc argument.
+ longlongValue() + +
+          get the long value of the osc argument.
+ int[]midiValue() + +
+           
+ StringstringValue() + +
+          get the String value of the osc argument.
+ StringtoString() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+OscArgument

+
+public OscArgument()
+
+
+ + + + + + + + +
+Method Detail
+ +

+intValue

+
+public int intValue()
+
+
get the int value of the osc argument. +

+

+ +
Returns:
int +
+Example
/**
+ * oscP5parsing by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an
+ * alternative and more convenient way to parse messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create a new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(12.34); /* add a float to the osc message */
+  myMessage.add("some text"); /* add a string to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+void oscEvent(OscMessage theOscMessage) {
+  /* check if theOscMessage has the address pattern we are looking for. */
+  
+  if(theOscMessage.checkAddrPattern("/test")==true) {
+    /* check if the typetag is the right one. */
+    if(theOscMessage.checkTypetag("ifs")) {
+      /* parse theOscMessage and extract the values from the osc message arguments. */
+      int firstValue = theOscMessage.get(0).intValue();  
+      float secondValue = theOscMessage.get(1).floatValue();
+      String thirdValue = theOscMessage.get(2).stringValue();
+      print("### received an osc message /test with typetag ifs.");
+      println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+      return;
+    }  
+  } 
+  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
+}
+
+
+
+
+ +

+charValue

+
+public char charValue()
+
+
get the char value of the osc argument. +

+

+ +
Returns:
char +
+Example
/**
+ * oscP5parsing by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an
+ * alternative and more convenient way to parse messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create a new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(12.34); /* add a float to the osc message */
+  myMessage.add("some text"); /* add a string to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+void oscEvent(OscMessage theOscMessage) {
+  /* check if theOscMessage has the address pattern we are looking for. */
+  
+  if(theOscMessage.checkAddrPattern("/test")==true) {
+    /* check if the typetag is the right one. */
+    if(theOscMessage.checkTypetag("ifs")) {
+      /* parse theOscMessage and extract the values from the osc message arguments. */
+      int firstValue = theOscMessage.get(0).intValue();  
+      float secondValue = theOscMessage.get(1).floatValue();
+      String thirdValue = theOscMessage.get(2).stringValue();
+      print("### received an osc message /test with typetag ifs.");
+      println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+      return;
+    }  
+  } 
+  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
+}
+
+
+
+
+ +

+floatValue

+
+public float floatValue()
+
+
get the float value of the osc argument. +

+

+ +
Returns:
float +
+Example
/**
+ * oscP5parsing by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an
+ * alternative and more convenient way to parse messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create a new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(12.34); /* add a float to the osc message */
+  myMessage.add("some text"); /* add a string to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+void oscEvent(OscMessage theOscMessage) {
+  /* check if theOscMessage has the address pattern we are looking for. */
+  
+  if(theOscMessage.checkAddrPattern("/test")==true) {
+    /* check if the typetag is the right one. */
+    if(theOscMessage.checkTypetag("ifs")) {
+      /* parse theOscMessage and extract the values from the osc message arguments. */
+      int firstValue = theOscMessage.get(0).intValue();  
+      float secondValue = theOscMessage.get(1).floatValue();
+      String thirdValue = theOscMessage.get(2).stringValue();
+      print("### received an osc message /test with typetag ifs.");
+      println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+      return;
+    }  
+  } 
+  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
+}
+
+
+
+
+ +

+doubleValue

+
+public double doubleValue()
+
+
get the double value of the osc argument. +

+

+ +
Returns:
double +
+Example
/**
+ * oscP5parsing by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an
+ * alternative and more convenient way to parse messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create a new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(12.34); /* add a float to the osc message */
+  myMessage.add("some text"); /* add a string to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+void oscEvent(OscMessage theOscMessage) {
+  /* check if theOscMessage has the address pattern we are looking for. */
+  
+  if(theOscMessage.checkAddrPattern("/test")==true) {
+    /* check if the typetag is the right one. */
+    if(theOscMessage.checkTypetag("ifs")) {
+      /* parse theOscMessage and extract the values from the osc message arguments. */
+      int firstValue = theOscMessage.get(0).intValue();  
+      float secondValue = theOscMessage.get(1).floatValue();
+      String thirdValue = theOscMessage.get(2).stringValue();
+      print("### received an osc message /test with typetag ifs.");
+      println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+      return;
+    }  
+  } 
+  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
+}
+
+
+
+
+ +

+longValue

+
+public long longValue()
+
+
get the long value of the osc argument. +

+

+ +
Returns:
long +
+Example
/**
+ * oscP5parsing by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an
+ * alternative and more convenient way to parse messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create a new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(12.34); /* add a float to the osc message */
+  myMessage.add("some text"); /* add a string to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+void oscEvent(OscMessage theOscMessage) {
+  /* check if theOscMessage has the address pattern we are looking for. */
+  
+  if(theOscMessage.checkAddrPattern("/test")==true) {
+    /* check if the typetag is the right one. */
+    if(theOscMessage.checkTypetag("ifs")) {
+      /* parse theOscMessage and extract the values from the osc message arguments. */
+      int firstValue = theOscMessage.get(0).intValue();  
+      float secondValue = theOscMessage.get(1).floatValue();
+      String thirdValue = theOscMessage.get(2).stringValue();
+      print("### received an osc message /test with typetag ifs.");
+      println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+      return;
+    }  
+  } 
+  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
+}
+
+
+
+
+ +

+booleanValue

+
+public boolean booleanValue()
+
+
get the boolean value of the osc argument. +

+

+ +
Returns:
boolean +
+Example
/**
+ * oscP5parsing by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an
+ * alternative and more convenient way to parse messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create a new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(12.34); /* add a float to the osc message */
+  myMessage.add("some text"); /* add a string to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+void oscEvent(OscMessage theOscMessage) {
+  /* check if theOscMessage has the address pattern we are looking for. */
+  
+  if(theOscMessage.checkAddrPattern("/test")==true) {
+    /* check if the typetag is the right one. */
+    if(theOscMessage.checkTypetag("ifs")) {
+      /* parse theOscMessage and extract the values from the osc message arguments. */
+      int firstValue = theOscMessage.get(0).intValue();  
+      float secondValue = theOscMessage.get(1).floatValue();
+      String thirdValue = theOscMessage.get(2).stringValue();
+      print("### received an osc message /test with typetag ifs.");
+      println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+      return;
+    }  
+  } 
+  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
+}
+
+
+
+
+ +

+stringValue

+
+public String stringValue()
+
+
get the String value of the osc argument. +

+

+ +
Returns:
String +
+Example
/**
+ * oscP5parsing by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an
+ * alternative and more convenient way to parse messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create a new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(12.34); /* add a float to the osc message */
+  myMessage.add("some text"); /* add a string to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+void oscEvent(OscMessage theOscMessage) {
+  /* check if theOscMessage has the address pattern we are looking for. */
+  
+  if(theOscMessage.checkAddrPattern("/test")==true) {
+    /* check if the typetag is the right one. */
+    if(theOscMessage.checkTypetag("ifs")) {
+      /* parse theOscMessage and extract the values from the osc message arguments. */
+      int firstValue = theOscMessage.get(0).intValue();  
+      float secondValue = theOscMessage.get(1).floatValue();
+      String thirdValue = theOscMessage.get(2).stringValue();
+      print("### received an osc message /test with typetag ifs.");
+      println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+      return;
+    }  
+  } 
+  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
+}
+
+
+
+
+ +

+toString

+
+public String toString()
+
+
+
Overrides:
toString in class Object
+
+
+ +
Returns:
String
+
+
+
+ +

+bytesValue

+
+public byte[] bytesValue()
+
+
get the byte array of the osc argument. +

+

+ +
Returns:
byte[] +
+Example
/**
+ * oscP5parsing by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an
+ * alternative and more convenient way to parse messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create a new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(12.34); /* add a float to the osc message */
+  myMessage.add("some text"); /* add a string to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+void oscEvent(OscMessage theOscMessage) {
+  /* check if theOscMessage has the address pattern we are looking for. */
+  
+  if(theOscMessage.checkAddrPattern("/test")==true) {
+    /* check if the typetag is the right one. */
+    if(theOscMessage.checkTypetag("ifs")) {
+      /* parse theOscMessage and extract the values from the osc message arguments. */
+      int firstValue = theOscMessage.get(0).intValue();  
+      float secondValue = theOscMessage.get(1).floatValue();
+      String thirdValue = theOscMessage.get(2).stringValue();
+      print("### received an osc message /test with typetag ifs.");
+      println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+      return;
+    }  
+  } 
+  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
+}
+
+
+
+
+ +

+blobValue

+
+public byte[] blobValue()
+
+
get the byte array (blob) of the osc argument. +

+

+ +
Returns:
byte[] +
+Example
/**
+ * oscP5parsing by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an
+ * alternative and more convenient way to parse messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create a new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(12.34); /* add a float to the osc message */
+  myMessage.add("some text"); /* add a string to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+void oscEvent(OscMessage theOscMessage) {
+  /* check if theOscMessage has the address pattern we are looking for. */
+  
+  if(theOscMessage.checkAddrPattern("/test")==true) {
+    /* check if the typetag is the right one. */
+    if(theOscMessage.checkTypetag("ifs")) {
+      /* parse theOscMessage and extract the values from the osc message arguments. */
+      int firstValue = theOscMessage.get(0).intValue();  
+      float secondValue = theOscMessage.get(1).floatValue();
+      String thirdValue = theOscMessage.get(2).stringValue();
+      print("### received an osc message /test with typetag ifs.");
+      println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+      return;
+    }  
+  } 
+  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
+}
+
+
+
+
+ +

+midiValue

+
+public int[] midiValue()
+
+
+ +
Returns:
int[]
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/OscBundle.html b/libraries/oscP5/reference/oscP5/OscBundle.html new file mode 100644 index 0000000..e3c10d9 --- /dev/null +++ b/libraries/oscP5/reference/oscP5/OscBundle.html @@ -0,0 +1,765 @@ + + + + + + +OscBundle (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +oscP5 +
+Class OscBundle

+
+java.lang.Object
+  extended by oscP5.OscPatcher
+      extended by oscP5.OscPacket
+          extended by oscP5.OscBundle
+
+
+
+
public class OscBundle
extends OscPacket
+ + +

+Osc Bundles are collections of Osc Messages. use bundles to send multiple + osc messages to one destination. the OscBundle timetag is supported for + sending but not for receiving yet. +

+ +

+

+ +
+Example
/**
+ * oscP5bundle by andreas schlegel
+ * an osc broadcast server.
+ * example shows how to create and send osc bundles. 
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create an osc bundle */
+  OscBundle myBundle = new OscBundle();
+  
+  /* createa new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  myMessage.add("abc");
+  
+  /* add an osc message to the osc bundle */
+  myBundle.add(myMessage);
+  
+  /* reset and clear the myMessage object for refill. */
+  myMessage.clear();
+  
+  /* refill the osc message object again */
+  myMessage.setAddrPattern("/test2");
+  myMessage.add("defg");
+  myBundle.add(myMessage);
+  
+  myBundle.setTimetag(myBundle.now() + 10000);
+  /* send the osc bundle, containing 2 osc messages, to a remote location. */
+  oscP5.send(myBundle, myRemoteLocation);
+}
+
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+  /* print the address pattern and the typetag of the received OscMessage */
+  print("### received an osc message.");
+  print(" addrpattern: "+theOscMessage.addrPattern());
+  print(" typetag: "+theOscMessage.typetag());
+  println(" timetag: "+theOscMessage.timetag());
+}
+
+
+ +

+ + + + + + + + + + + +
+Constructor Summary
OscBundle() + +
+          instantiate a new OscBundle object.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidadd(OscMessage theOscMessage) + +
+          add an osc message to the osc bundle.
+ voidclear() + +
+          clear and reset the osc bundle for reusing.
+ byte[]getBytes() + +
+           
+ OscMessagegetMessage(int theIndex) + +
+          request an osc message inside the osc bundle array,
+static longnow() + +
+          returns the current time in milliseconds.
+ voidremove(int theIndex) + +
+          remove an OscMessage from an OscBundle.
+ voidremove(OscMessage theOscMessage) + +
+           
+ voidsetTimetag(long theTime) + +
+          set the timetag of an osc bundle.
+ intsize() + +
+          get the size of the osc bundle array which contains the osc messages.
+ byte[]timetag() + +
+          returns a timetag as byte array.
+ + + + + + + +
Methods inherited from class oscP5.OscPacket
address, netaddress, netAddress, port, tcpConnection
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+OscBundle

+
+public OscBundle()
+
+
instantiate a new OscBundle object. +

+

+ + + + + + + + +
+Method Detail
+ +

+add

+
+public void add(OscMessage theOscMessage)
+
+
add an osc message to the osc bundle. +

+

+
Parameters:
theOscMessage - OscMessage
+
+
+
+ +

+clear

+
+public void clear()
+
+
clear and reset the osc bundle for reusing. +

+

+ +
+Example
/**
+ * oscP5bundle by andreas schlegel
+ * an osc broadcast server.
+ * example shows how to create and send osc bundles. 
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create an osc bundle */
+  OscBundle myBundle = new OscBundle();
+  
+  /* createa new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  myMessage.add("abc");
+  
+  /* add an osc message to the osc bundle */
+  myBundle.add(myMessage);
+  
+  /* reset and clear the myMessage object for refill. */
+  myMessage.clear();
+  
+  /* refill the osc message object again */
+  myMessage.setAddrPattern("/test2");
+  myMessage.add("defg");
+  myBundle.add(myMessage);
+  
+  myBundle.setTimetag(myBundle.now() + 10000);
+  /* send the osc bundle, containing 2 osc messages, to a remote location. */
+  oscP5.send(myBundle, myRemoteLocation);
+}
+
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+  /* print the address pattern and the typetag of the received OscMessage */
+  print("### received an osc message.");
+  print(" addrpattern: "+theOscMessage.addrPattern());
+  print(" typetag: "+theOscMessage.typetag());
+  println(" timetag: "+theOscMessage.timetag());
+}
+
+
+
+
+ +

+remove

+
+public void remove(int theIndex)
+
+
remove an OscMessage from an OscBundle. +

+

+
Parameters:
theIndex - int
+
+
+
+ +

+remove

+
+public void remove(OscMessage theOscMessage)
+
+
+
Parameters:
theOscMessage - OscMessage
+
+
+
+ +

+getMessage

+
+public OscMessage getMessage(int theIndex)
+
+
request an osc message inside the osc bundle array, +

+

+
Parameters:
theIndex - int +
Returns:
OscMessage
+
+
+
+ +

+size

+
+public int size()
+
+
get the size of the osc bundle array which contains the osc messages. +

+

+ +
Returns:
int +
+Example
/**
+ * oscP5bundle by andreas schlegel
+ * an osc broadcast server.
+ * example shows how to create and send osc bundles. 
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create an osc bundle */
+  OscBundle myBundle = new OscBundle();
+  
+  /* createa new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  myMessage.add("abc");
+  
+  /* add an osc message to the osc bundle */
+  myBundle.add(myMessage);
+  
+  /* reset and clear the myMessage object for refill. */
+  myMessage.clear();
+  
+  /* refill the osc message object again */
+  myMessage.setAddrPattern("/test2");
+  myMessage.add("defg");
+  myBundle.add(myMessage);
+  
+  myBundle.setTimetag(myBundle.now() + 10000);
+  /* send the osc bundle, containing 2 osc messages, to a remote location. */
+  oscP5.send(myBundle, myRemoteLocation);
+}
+
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+  /* print the address pattern and the typetag of the received OscMessage */
+  print("### received an osc message.");
+  print(" addrpattern: "+theOscMessage.addrPattern());
+  print(" typetag: "+theOscMessage.typetag());
+  println(" timetag: "+theOscMessage.timetag());
+}
+
+
+
+
+ +

+setTimetag

+
+public void setTimetag(long theTime)
+
+
set the timetag of an osc bundle. timetags are used to synchronize events and + execute events at a given time in the future or immediately. timetags can + only be set for osc bundles, not for osc messages. oscP5 supports receiving + timetags, but does not queue messages for execution at a set time. +

+

+
Parameters:
theTime - long +
+Example
/**
+ * oscP5bundle by andreas schlegel
+ * an osc broadcast server.
+ * example shows how to create and send osc bundles. 
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create an osc bundle */
+  OscBundle myBundle = new OscBundle();
+  
+  /* createa new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  myMessage.add("abc");
+  
+  /* add an osc message to the osc bundle */
+  myBundle.add(myMessage);
+  
+  /* reset and clear the myMessage object for refill. */
+  myMessage.clear();
+  
+  /* refill the osc message object again */
+  myMessage.setAddrPattern("/test2");
+  myMessage.add("defg");
+  myBundle.add(myMessage);
+  
+  myBundle.setTimetag(myBundle.now() + 10000);
+  /* send the osc bundle, containing 2 osc messages, to a remote location. */
+  oscP5.send(myBundle, myRemoteLocation);
+}
+
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+  /* print the address pattern and the typetag of the received OscMessage */
+  print("### received an osc message.");
+  print(" addrpattern: "+theOscMessage.addrPattern());
+  print(" typetag: "+theOscMessage.typetag());
+  println(" timetag: "+theOscMessage.timetag());
+}
+
+
+
+
+ +

+now

+
+public static long now()
+
+
returns the current time in milliseconds. use with setTimetag. +

+

+ +
Returns:
long
+
+
+
+ +

+timetag

+
+public byte[] timetag()
+
+
returns a timetag as byte array. +

+

+ +
Returns:
byte[]
+
+
+
+ +

+getBytes

+
+public byte[] getBytes()
+
+
+
Specified by:
getBytes in class OscPacket
+
+
+ +
Returns:
byte[]
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/OscEventListener.html b/libraries/oscP5/reference/oscP5/OscEventListener.html new file mode 100644 index 0000000..dac1c19 --- /dev/null +++ b/libraries/oscP5/reference/oscP5/OscEventListener.html @@ -0,0 +1,223 @@ + + + + + + +OscEventListener (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +oscP5 +
+Interface OscEventListener

+
+
+
public interface OscEventListener
+ + +

+


+ +

+ + + + + + + + + + + + + + + + +
+Method Summary
+ voidoscEvent(OscMessage theMessage) + +
+           
+ voidoscStatus(OscStatus theStatus) + +
+           
+  +

+ + + + + + + + +
+Method Detail
+ +

+oscEvent

+
+void oscEvent(OscMessage theMessage)
+
+
+
+
+
+
+ +

+oscStatus

+
+void oscStatus(OscStatus theStatus)
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/OscIn.html b/libraries/oscP5/reference/oscP5/OscIn.html new file mode 100644 index 0000000..4a3eafb --- /dev/null +++ b/libraries/oscP5/reference/oscP5/OscIn.html @@ -0,0 +1,434 @@ + + + + + + +OscIn (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +oscP5 +
+Class OscIn

+
+java.lang.Object
+  extended by oscP5.OscPatcher
+      extended by oscP5.OscPacket
+          extended by oscP5.OscMessage
+              extended by oscP5.OscIn
+
+
+Deprecated. +

+

+
@Deprecated
+public class OscIn
extends OscMessage
+ + +

+OscIn is deprecated. for compatibility with previous versions of oscP5 OscIn + is still available. +

+ +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
OscIn(OscMessage theOscMessage) + +
+          Deprecated.  
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ byte[]getBlob(int thePos) + +
+          Deprecated.  
+ booleangetBoolean(int thePos) + +
+          Deprecated.  
+ chargetChar(int thePos) + +
+          Deprecated.  
+ ArrayListgetDataList() + +
+          Deprecated. this is only for christian's and jens' table communication with vvvv.
+ floatgetFloat(int thePos) + +
+          Deprecated.  
+ intgetInt(int thePos) + +
+          Deprecated.  
+ int[]getMidi(int thePos) + +
+          Deprecated.  
+ int[]getMidiBytes(int thePos) + +
+          Deprecated.  
+ StringgetString(int thePos) + +
+          Deprecated.  
+ + + + + + + +
Methods inherited from class oscP5.OscMessage
add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, add, addArguments, addrInt, addrPattern, arguments, checkAddrPattern, checkTypetag, clear, clearArguments, get, getAddrPatternAsBytes, getBytes, getTypetagAsBytes, isPlugged, makeBlob, print, printData, set, setAddrPattern, setAddrPattern, setArguments, timetag, toString, typetag
+ + + + + + + +
Methods inherited from class oscP5.OscPacket
address, netaddress, netAddress, port, tcpConnection
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+OscIn

+
+public OscIn(OscMessage theOscMessage)
+
+
Deprecated. 
+ + + + + + + + +
+Method Detail
+ +

+getInt

+
+public int getInt(int thePos)
+
+
Deprecated. 
+
+
+
+
+ +

+getChar

+
+public char getChar(int thePos)
+
+
Deprecated. 
+
+
+
+
+ +

+getFloat

+
+public float getFloat(int thePos)
+
+
Deprecated. 
+
+
+
+
+ +

+getString

+
+public String getString(int thePos)
+
+
Deprecated. 
+
+
+
+
+ +

+getBlob

+
+public byte[] getBlob(int thePos)
+
+
Deprecated. 
+
+
+
+
+ +

+getMidiBytes

+
+public int[] getMidiBytes(int thePos)
+
+
Deprecated. 
+
+
+
+
+ +

+getMidi

+
+public int[] getMidi(int thePos)
+
+
Deprecated. 
+
+
+
+
+ +

+getBoolean

+
+public boolean getBoolean(int thePos)
+
+
Deprecated. 
+
+
+
+
+ +

+getDataList

+
+public ArrayList getDataList()
+
+
Deprecated. 
this is only for christian's and jens' table communication with vvvv. +

+

+ +
Returns:
ArrayList
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/OscMessage.html b/libraries/oscP5/reference/oscP5/OscMessage.html new file mode 100644 index 0000000..3bb21cb --- /dev/null +++ b/libraries/oscP5/reference/oscP5/OscMessage.html @@ -0,0 +1,1447 @@ + + + + + + +OscMessage (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +oscP5 +
+Class OscMessage

+
+java.lang.Object
+  extended by oscP5.OscPatcher
+      extended by oscP5.OscPacket
+          extended by oscP5.OscMessage
+
+
+
Direct Known Subclasses:
OscIn
+
+
+
+
public class OscMessage
extends OscPacket
+ + +

+An OSC message consists of an OSC Address Pattern, an OSC Type Tag String + and the OSC arguments. +

+ +

+

+ +
+Example
/**
+ * oscP5sendreceive by andreas schlegel
+ * example shows how to send and receive osc messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+ 
+import oscP5.*;
+import netP5.*;
+  
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+
+void draw() {
+  background(0);  
+}
+
+void mousePressed() {
+  /* in the following different ways of creating osc messages are shown by example */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+  /* print the address pattern and the typetag of the received OscMessage */
+  print("### received an osc message.");
+  print(" addrpattern: "+theOscMessage.addrPattern());
+  println(" typetag: "+theOscMessage.typetag());
+}
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + +
+Constructor Summary
OscMessage(int theAddrInt) + +
+           
OscMessage(int theAddrPattern, + Object[] theArguments) + +
+           
OscMessage(OscMessage theOscMessage) + +
+           
OscMessage(String theAddrPattern) + +
+           
OscMessage(String theAddrPattern, + Object[] theArguments) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ OscMessageadd() + +
+          add values to an osc message.
+ OscMessageadd(boolean theValue) + +
+           
+ OscMessageadd(Boolean theValue) + +
+           
+ OscMessageadd(byte[] theArray) + +
+           
+ OscMessageadd(char theValue) + +
+           
+ OscMessageadd(char[] theArray) + +
+           
+ OscMessageadd(Character theValue) + +
+           
+ OscMessageadd(double theValue) + +
+           
+ OscMessageadd(Double theValue) + +
+           
+ OscMessageadd(float theValue) + +
+           
+ OscMessageadd(Float theValue) + +
+           
+ OscMessageadd(float[] theArray) + +
+           
+ OscMessageadd(int theValue) + +
+           
+ OscMessageadd(int[] theArray) + +
+           
+ OscMessageadd(Integer theValue) + +
+           
+ OscMessageadd(int channel, + int status, + int value1, + int value2) + +
+           
+ OscMessageadd(Object[] theArray) + +
+           
+ OscMessageadd(String theValue) + +
+           
+ OscMessageadd(String[] theArray) + +
+           
+ OscMessageaddArguments(Object[] theArguments) + +
+          add a list of arguments to an exisiting set of arguments.
+ intaddrInt() + +
+          returns the address pattern of the osc message as int.
+ StringaddrPattern() + +
+           
+ Object[]arguments() + +
+           
+ booleancheckAddrPattern(String theAddrPattern) + +
+          check if an address pattern equals a specific address pattern + you are looking for.
+ booleancheckTypetag(String theTypeTag) + +
+           
+ voidclear() + +
+          clear and reset an OscMessage for reuse.
+ voidclearArguments() + +
+          clears the arguments in a message, + but keeps the address the address pattern.
+ OscArgumentget(int theIndex) + +
+          get a value at a specific position in the osc message.
+ byte[]getAddrPatternAsBytes() + +
+           
+ byte[]getBytes() + +
+           
+ byte[]getTypetagAsBytes() + +
+           
+ booleanisPlugged() + +
+           
+static byte[]makeBlob(byte[] b) + +
+           
+ voidprint() + +
+           
+ voidprintData() + +
+           
+ voidset(int theIndex, + Object theObject) + +
+          TODO + set should enable the programmer to set values + of an existing osc message.
+ voidsetAddrPattern(int theAddrPattern) + +
+           
+ voidsetAddrPattern(String theAddrPattern) + +
+          set the address pattern of an osc message.
+ voidsetArguments(Object[] theArguments) + +
+          set the arguments of the osc message using an object array.
+ longtimetag() + +
+          get the timetag of an osc message.
+ StringtoString() + +
+           
+ Stringtypetag() + +
+          returns the typetag of the osc message.
+ + + + + + + +
Methods inherited from class oscP5.OscPacket
address, netaddress, netAddress, port, tcpConnection
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+OscMessage

+
+public OscMessage(OscMessage theOscMessage)
+
+
+
Parameters:
theOscMessage - OscMessage
+
+
+ +

+OscMessage

+
+public OscMessage(String theAddrPattern)
+
+
+
Parameters:
theAddrPattern - String
+
+
+ +

+OscMessage

+
+public OscMessage(int theAddrInt)
+
+
+
Parameters:
theAddrInt - int
+
+
+ +

+OscMessage

+
+public OscMessage(String theAddrPattern,
+                  Object[] theArguments)
+
+
+
Parameters:
theAddrPattern - String
theArguments - Object[]
+
+
+ +

+OscMessage

+
+public OscMessage(int theAddrPattern,
+                  Object[] theArguments)
+
+
+
Parameters:
theAddrPattern - int
theArguments - Object[]
+
+ + + + + + + + +
+Method Detail
+ +

+clear

+
+public void clear()
+
+
clear and reset an OscMessage for reuse. +

+

+
+
+
+
+ +

+clearArguments

+
+public void clearArguments()
+
+
clears the arguments in a message, + but keeps the address the address pattern. +

+

+
+
+
+
+ +

+set

+
+public void set(int theIndex,
+                Object theObject)
+
+
TODO + set should enable the programmer to set values + of an existing osc message. +

+

+
+
+
+
+ +

+checkTypetag

+
+public boolean checkTypetag(String theTypeTag)
+
+
+
Parameters:
theTypeTag - String +
Returns:
boolean +
+Example
/**
+ * oscP5parsing by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an
+ * alternative and more convenient way to parse messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create a new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(12.34); /* add a float to the osc message */
+  myMessage.add("some text"); /* add a string to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+void oscEvent(OscMessage theOscMessage) {
+  /* check if theOscMessage has the address pattern we are looking for. */
+  
+  if(theOscMessage.checkAddrPattern("/test")==true) {
+    /* check if the typetag is the right one. */
+    if(theOscMessage.checkTypetag("ifs")) {
+      /* parse theOscMessage and extract the values from the osc message arguments. */
+      int firstValue = theOscMessage.get(0).intValue();  
+      float secondValue = theOscMessage.get(1).floatValue();
+      String thirdValue = theOscMessage.get(2).stringValue();
+      print("### received an osc message /test with typetag ifs.");
+      println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+      return;
+    }  
+  } 
+  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
+}
+
+
+
+
+ +

+checkAddrPattern

+
+public boolean checkAddrPattern(String theAddrPattern)
+
+
check if an address pattern equals a specific address pattern + you are looking for. this is usually used when parsing an osc message. + e.g. if(theOscMessage.checkAddrPattern("/test")==true) {...} +

+

+
Parameters:
theAddrPattern - String +
Returns:
boolean +
+Example
/**
+ * oscP5parsing by andreas schlegel
+ * example shows how to parse incoming osc messages "by hand".
+ * it is recommended to take a look at oscP5plug for an
+ * alternative and more convenient way to parse messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+void draw() {
+  background(0);  
+}
+
+
+void mousePressed() {
+  /* create a new osc message object */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(12.34); /* add a float to the osc message */
+  myMessage.add("some text"); /* add a string to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+void oscEvent(OscMessage theOscMessage) {
+  /* check if theOscMessage has the address pattern we are looking for. */
+  
+  if(theOscMessage.checkAddrPattern("/test")==true) {
+    /* check if the typetag is the right one. */
+    if(theOscMessage.checkTypetag("ifs")) {
+      /* parse theOscMessage and extract the values from the osc message arguments. */
+      int firstValue = theOscMessage.get(0).intValue();  
+      float secondValue = theOscMessage.get(1).floatValue();
+      String thirdValue = theOscMessage.get(2).stringValue();
+      print("### received an osc message /test with typetag ifs.");
+      println(" values: "+firstValue+", "+secondValue+", "+thirdValue);
+      return;
+    }  
+  } 
+  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
+}
+
+
+
+
+ +

+setAddrPattern

+
+public void setAddrPattern(String theAddrPattern)
+
+
set the address pattern of an osc message. you can set + a string or an int as address pattern.tnt might be useful for + supercollider users. oscP5 does support ints and strings as + address patterns when sending and receiving messages. +

+

+
Parameters:
theAddrPattern - String
+
+
+
+ +

+setAddrPattern

+
+public void setAddrPattern(int theAddrPattern)
+
+
+
Parameters:
theAddrPattern - int
+
+
+
+ +

+setArguments

+
+public void setArguments(Object[] theArguments)
+
+
set the arguments of the osc message using an object array. + with version 0.9.4 the existing arguments are overwritten, + to add the arguments to the argument list, use addArguments(Object[]) +

+

+
Parameters:
theArguments - Object[]
+
+
+
+ +

+addArguments

+
+public OscMessage addArguments(Object[] theArguments)
+
+
add a list of arguments to an exisiting set of arguments. + to overwrite the existing argument list, use setArguments(Object[]) +

+

+
Parameters:
theArguments -
+
+
+
+ +

+addrPattern

+
+public String addrPattern()
+
+
+
+
+
+
+ +

+addrInt

+
+public int addrInt()
+
+
returns the address pattern of the osc message as int. +

+

+ +
Returns:
int
+
+
+
+ +

+typetag

+
+public String typetag()
+
+
returns the typetag of the osc message. e.g. the message contains + 3 floats then the typetag would be "fff" +

+

+ +
Returns:
String
+
+
+
+ +

+timetag

+
+public long timetag()
+
+
get the timetag of an osc message. timetags are only sent by + osc bundles. +

+

+ +
Returns:
long
+
+
+
+ +

+arguments

+
+public Object[] arguments()
+
+
+ +
Returns:
Object[]
+
+
+
+ +

+getAddrPatternAsBytes

+
+public byte[] getAddrPatternAsBytes()
+
+
+ +
Returns:
byte[]
+
+
+
+ +

+getTypetagAsBytes

+
+public byte[] getTypetagAsBytes()
+
+
+ +
Returns:
byte[]
+
+
+
+ +

+getBytes

+
+public byte[] getBytes()
+
+
+
Specified by:
getBytes in class OscPacket
+
+
+ +
Returns:
byte[]
+
+
+
+ +

+add

+
+public OscMessage add()
+
+
add values to an osc message. please check the + add documentation for specific information. +

+

+ +
+Example
/**
+ * oscP5message by andreas schlegel
+ * example shows how to create osc messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+ 
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+
+void draw() {
+  background(0);  
+}
+
+void mousePressed() {
+  /* in the following different ways of creating osc messages are shown by example */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(12.34); /* add a float to the osc message */
+  myMessage.add("some text"); /* add a string to the osc message */
+  myMessage.add(new byte[] {0x00, 0x01, 0x10, 0x20}); /* add a byte blob to the osc message */
+  myMessage.add(new int[] {1,2,3,4}); /* add an int array to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+  /* print the address pattern and the typetag of the received OscMessage */
+  print("### received an osc message.");
+  print(" addrpattern: "+theOscMessage.addrPattern());
+  println(" typetag: "+theOscMessage.typetag());
+}
+
+
+
+
+ +

+add

+
+public OscMessage add(int theValue)
+
+
+
Parameters:
theValue - int
+
+
+
+ +

+add

+
+public OscMessage add(String theValue)
+
+
+
Parameters:
theValue - String
+
+
+
+ +

+add

+
+public OscMessage add(float theValue)
+
+
+
Parameters:
theValue - float
+
+
+
+ +

+add

+
+public OscMessage add(double theValue)
+
+
+
Parameters:
theValue - double
+
+
+
+ +

+add

+
+public OscMessage add(boolean theValue)
+
+
+
Parameters:
theValue - boolean
+
+
+
+ +

+add

+
+public OscMessage add(Boolean theValue)
+
+
+
Parameters:
theValue - Boolean
+
+
+
+ +

+add

+
+public OscMessage add(Integer theValue)
+
+
+
Parameters:
theValue - Integer
+
+
+
+ +

+add

+
+public OscMessage add(Float theValue)
+
+
+
Parameters:
theValue - Float
+
+
+
+ +

+add

+
+public OscMessage add(Double theValue)
+
+
+
Parameters:
theValue - Double
+
+
+
+ +

+add

+
+public OscMessage add(Character theValue)
+
+
+
Parameters:
theValue - Character
+
+
+
+ +

+add

+
+public OscMessage add(char theValue)
+
+
+
Parameters:
theValue - char
+
+
+
+ +

+add

+
+public OscMessage add(int channel,
+                      int status,
+                      int value1,
+                      int value2)
+
+
+
Parameters:
channel - int
status - int
value1 - int
value2 - int
+
+
+
+ +

+add

+
+public OscMessage add(int[] theArray)
+
+
+
Parameters:
theArray - int[]
+
+
+
+ +

+add

+
+public OscMessage add(char[] theArray)
+
+
+
Parameters:
theArray - char[]
+
+
+
+ +

+add

+
+public OscMessage add(float[] theArray)
+
+
+
Parameters:
theArray - float[]
+
+
+
+ +

+add

+
+public OscMessage add(String[] theArray)
+
+
+
Parameters:
theArray - String[]
+
+
+
+ +

+add

+
+public OscMessage add(byte[] theArray)
+
+
+
Parameters:
theArray - byte[]
+
+
+
+ +

+add

+
+public OscMessage add(Object[] theArray)
+
+
+
Parameters:
theArray - Object[]
+
+
+
+ +

+makeBlob

+
+public static byte[] makeBlob(byte[] b)
+
+
+
Parameters:
b - byte[] +
Returns:
byte[]
+
+
+
+ +

+get

+
+public OscArgument get(int theIndex)
+
+
get a value at a specific position in the osc message. the get method + returns an OscArgument from which the value can be parsed into the right + format. e.g. to parse an int from the first argument in the osc message, + use theOscMessage.get(0).intValue(); +

+

+
Parameters:
theIndex - int +
Returns:
OscArgument
+
+
+
+ +

+toString

+
+public final String toString()
+
+
+
Overrides:
toString in class Object
+
+
+ +
Returns:
String
+
+
+
+ +

+isPlugged

+
+public boolean isPlugged()
+
+
+
+
+
+
+ +

+print

+
+public void print()
+
+
+
+
+
+
+ +

+printData

+
+public void printData()
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/OscNetManager.html b/libraries/oscP5/reference/oscP5/OscNetManager.html new file mode 100644 index 0000000..1dd93e1 --- /dev/null +++ b/libraries/oscP5/reference/oscP5/OscNetManager.html @@ -0,0 +1,760 @@ + + + + + + +OscNetManager (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +oscP5 +
+Class OscNetManager

+
+java.lang.Object
+  extended by oscP5.OscNetManager
+
+
+
All Implemented Interfaces:
TcpPacketListener, UdpPacketListener
+
+
+
+
public class OscNetManager
extends Object
implements UdpPacketListener, TcpPacketListener
+ + +

+


+ +

+ + + + + + + + + + + +
+Field Summary
+static intNONE + +
+           
+  + + + + + + + + + + +
+Constructor Summary
OscNetManager() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidaddTcpListener(TcpPacketListener theListener) + +
+           
+ voidaddUdpListener(UdpPacketListener theListener) + +
+           
+ voidprocess(DatagramPacket thePacket, + int thePort) + +
+           
+ voidprocess(TcpPacket thePacket, + int thePort) + +
+           
+ voidremove(AbstractTcpClient theClient) + +
+           
+ voidremoveTcpListener(TcpPacketListener theListener) + +
+           
+ voidremoveUdpListener(UdpPacketListener theListener) + +
+           
+ voidsend(DatagramPacket thePacket) + +
+           
+ voidsend(OscPacket thePacket) + +
+           
+ voidsend(OscPacket thePacket, + NetAddress theHost) + +
+           
+ voidsend(OscPacket thePacket, + NetAddressList theList) + +
+           
+ voidsend(OscPacket thePacket, + String theAddress, + int thePort) + +
+           
+ voidsend(String theAddrPattern, + Object[] theArguments) + +
+           
+ voidsend(String theAddrPattern, + Object[] theArguments, + NetAddress theHost) + +
+           
+ voidsend(String theAddrPattern, + Object[] theArguments, + NetAddressList theList) + +
+           
+ voidsend(String theAddrPattern, + Object[] theArguments, + String theAddress, + int thePort) + +
+           
+ voidsetTimeToLive(int theTTL) + +
+           
+ voidstart(OscProperties theOscProperties) + +
+           
+ voidstatus(int theIndex) + +
+           
+ TcpClienttcpClient() + +
+           
+ TcpServertcpServer() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+NONE

+
+public static final int NONE
+
+
+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+OscNetManager

+
+public OscNetManager()
+
+
+ + + + + + + + +
+Method Detail
+ +

+start

+
+public void start(OscProperties theOscProperties)
+
+
+
+
+
+
+
+
+
+ +

+setTimeToLive

+
+public void setTimeToLive(int theTTL)
+
+
+
+
+
+
+
+
+
+ +

+tcpServer

+
+public TcpServer tcpServer()
+
+
+
+
+
+
+
+
+
+ +

+tcpClient

+
+public TcpClient tcpClient()
+
+
+
+
+
+
+
+
+
+ +

+addUdpListener

+
+public void addUdpListener(UdpPacketListener theListener)
+
+
+
+
+
+
Parameters:
theListener - DatagramPacketListener
+
+
+
+ +

+removeUdpListener

+
+public void removeUdpListener(UdpPacketListener theListener)
+
+
+
+
+
+
Parameters:
theListener - DatagramPacketListener
+
+
+
+ +

+addTcpListener

+
+public void addTcpListener(TcpPacketListener theListener)
+
+
+
+
+
+
Parameters:
theListener - TcpPacketListener
+
+
+
+ +

+removeTcpListener

+
+public void removeTcpListener(TcpPacketListener theListener)
+
+
+
+
+
+
Parameters:
theListener - TcpPacketListener
+
+
+
+ +

+send

+
+public void send(OscPacket thePacket)
+
+
+
+
+
+
Parameters:
thePacket - OscPacket
+
+
+
+ +

+send

+
+public void send(DatagramPacket thePacket)
+
+
+
+
+
+
+
+
+
+ +

+send

+
+public void send(OscPacket thePacket,
+                 String theAddress,
+                 int thePort)
+
+
+
+
+
+
Parameters:
thePacket - OscPacket
theAddress - String
thePort - int
+
+
+
+ +

+send

+
+public void send(OscPacket thePacket,
+                 NetAddressList theList)
+
+
+
+
+
+
Parameters:
thePacket - OscPacket
theList - OscHostList
+
+
+
+ +

+send

+
+public void send(OscPacket thePacket,
+                 NetAddress theHost)
+
+
+
+
+
+
Parameters:
thePacket - OscPacket
theHost - NetAddress
+
+
+
+ +

+send

+
+public void send(String theAddrPattern,
+                 Object[] theArguments)
+
+
+
+
+
+
Parameters:
theAddrPattern - String
theArguments - Object[]
+
+
+
+ +

+send

+
+public void send(String theAddrPattern,
+                 Object[] theArguments,
+                 String theAddress,
+                 int thePort)
+
+
+
+
+
+
+
+
+
+ +

+send

+
+public void send(String theAddrPattern,
+                 Object[] theArguments,
+                 NetAddressList theList)
+
+
+
+
+
+
+
+
+
+ +

+send

+
+public void send(String theAddrPattern,
+                 Object[] theArguments,
+                 NetAddress theHost)
+
+
+
+
+
+
+
+
+
+ +

+process

+
+public void process(DatagramPacket thePacket,
+                    int thePort)
+
+
+
Specified by:
process in interface UdpPacketListener
+
+
+
Parameters:
thePacket - DatagramPacket
+
+
+
+ +

+process

+
+public void process(TcpPacket thePacket,
+                    int thePort)
+
+
+
Specified by:
process in interface TcpPacketListener
+
+
+
+
+
+
+ +

+remove

+
+public void remove(AbstractTcpClient theClient)
+
+
+
Specified by:
remove in interface TcpPacketListener
+
+
+
+
+
+
+ +

+status

+
+public void status(int theIndex)
+
+
+
Specified by:
status in interface TcpPacketListener
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/OscP5.html b/libraries/oscP5/reference/oscP5/OscP5.html new file mode 100644 index 0000000..7537ab0 --- /dev/null +++ b/libraries/oscP5/reference/oscP5/OscP5.html @@ -0,0 +1,1807 @@ + + + + + + +OscP5 (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +oscP5 +
+Class OscP5

+
+java.lang.Object
+  extended by oscP5.OscP5
+
+
+
All Implemented Interfaces:
TcpPacketListener, UdpPacketListener
+
+
+
+
public class OscP5
extends Object
implements UdpPacketListener, TcpPacketListener
+ + +

+TODO add better error message handling for oscEvents, see this post + http://forum.processing.org/topic/oscp5-major-problems-with-error-handling# 25080000000811163 +

+ +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static intMULTICAST + +
+          a static variable used when creating an oscP5 instance with a sepcified network protocol.
+static booleanOFF + +
+           
+static booleanON + +
+           
+static intTCP + +
+          a static variable used when creating an oscP5 instance with a sepcified network protocol.
+static intUDP + +
+          a static variable used when creating an oscP5 instance with a sepcified network protocol.
+static StringVERSION + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + +
+Constructor Summary
OscP5(Object theParent, + int theReceiveAtPort) + +
+           
OscP5(Object theParent, + int theReceiveAtPort, + int theMode) + +
+           
OscP5(Object theParent, + OscProperties theProperties) + +
+           
OscP5(Object theParent, + String theAddress, + int thePort) + +
+          Deprecated.  
OscP5(Object theParent, + String theAddress, + int thePort, + int theMode) + +
+           
OscP5(Object theParent, + String theHost, + int theSendToPort, + int theReceiveAtPort, + String theMethodName) + +
+          Deprecated.  
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidaddListener(OscEventListener theListener) + +
+           
+ voidconnect(NetAddress theNetAddress, + String theName, + String[] theArguments) + +
+           
+ voiddisconnect(NetAddress theHost) + +
+           
+ voiddisconnectFromTEMP() + +
+          Deprecated.  
+ voiddispose() + +
+           
+static voidflush(byte[] theBytes, + NetAddress theNetAddress) + +
+           
+static voidflush(byte[] theBytes, + String theAddress, + int thePort) + +
+          Deprecated.  
+static voidflush(OscMessage theOscMessage, + NetAddress theNetAddress) + +
+          a static method to send an OscMessage straight out of the box without having to instantiate + oscP5.
+static voidflush(OscMessage theOscMessage, + String theAddress, + int thePort) + +
+          Deprecated.  
+static voidflush(OscPacket theOscPacket, + NetAddress theNetAddress) + +
+           
+static voidflush(String theAddrPattern, + Object[] theArguments, + NetAddress theNetAddress) + +
+           
+ Stringip() + +
+           
+ booleanisBroadcast() + +
+           
+ Vector<OscEventListener>listeners() + +
+           
+ NetInfonetInfo() + +
+          netinfo() returns an instance of a NetInfo Object from which you can get LAN and WAN + information.
+ OscBundlenewBundle() + +
+          Deprecated.  
+ OscMessagenewMsg(String theAddrPattern) + +
+          Deprecated.  
+ voidplug(Object theObject, + String theMethodName, + String theAddrPattern) + +
+           
+ voidplug(Object theObject, + String theMethodName, + String theAddrPattern, + String theTypeTag) + +
+          osc messages can be automatically forwarded to a specific method of an object.
+ voidprocess(DatagramPacket thePacket, + int thePort) + +
+          incoming osc messages from an udp socket are parsed, processed and forwarded to the parent.
+ voidprocess(TcpPacket thePacket, + int thePort) + +
+           
+ OscPropertiesproperties() + +
+          returns the current properties of oscP5.
+ voidremove(AbstractTcpClient theTcpClient) + +
+           
+ voidremoveListener(OscEventListener theListener) + +
+           
+ voidsend(OscPacket thePacket) + +
+           
+ voidsend(OscPacket thePacket, + NetAddress theNetAddress) + +
+          you can send osc packets in many different ways.
+ voidsend(OscPacket thePacket, + NetAddressList theNetAddressList) + +
+           
+ voidsend(OscPacket thePacket, + String theIpAddress, + int thePort) + +
+          Deprecated.  
+ voidsend(OscPacket thePacket, + TcpClient theClient) + +
+          send to tcp client
+ voidsend(String theAddrPattern, + Object[] theArguments) + +
+           
+ voidsend(String theAddrPattern, + Object[] theArguments, + NetAddress theNetAddress) + +
+           
+ voidsend(String theAddrPattern, + Object[] theArguments, + NetAddressList theNetAddressList) + +
+           
+ voidsend(String theAddrPattern, + Object[] theArguments, + String theAddress, + int thePort) + +
+           
+ voidsend(String theAddrPattern, + Object[] theArguments, + TcpClient theClient) + +
+           
+static voidsetLogStatus(int theValue) + +
+           
+static voidsetLogStatus(int theIndex, + int theValue) + +
+          oscP5 has a logging mechanism which prints out processes, warnings and errors into the + console window.
+ voidsetTimeToLive(int theTTL) + +
+          set timeToLive of a multicast packet.
+ voidstatus(int theIndex) + +
+           
+ voidstop() + +
+          stop oscP5 and close open Sockets.
+ TcpClienttcpClient() + +
+          return the instance of the running TCP client if in TCP mode.
+ TcpServertcpServer() + +
+          return the instance of the running TCP server if in TCP mode.
+ Stringversion() + +
+          get the current version of oscP5.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+ON

+
+public static final boolean ON
+
+
+
See Also:
Constant Field Values
+
+
+ +

+OFF

+
+public static final boolean OFF
+
+
+
See Also:
Constant Field Values
+
+
+ +

+UDP

+
+public static final int UDP
+
+
a static variable used when creating an oscP5 instance with a sepcified network protocol. +

+

+
See Also:
Constant Field Values
+
+
+ +

+MULTICAST

+
+public static final int MULTICAST
+
+
a static variable used when creating an oscP5 instance with a sepcified network protocol. +

+

+
See Also:
Constant Field Values
+
+
+ +

+TCP

+
+public static final int TCP
+
+
a static variable used when creating an oscP5 instance with a sepcified network protocol. +

+

+
See Also:
Constant Field Values
+
+
+ +

+VERSION

+
+public static final String VERSION
+
+
+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+OscP5

+
+public OscP5(Object theParent,
+             OscProperties theProperties)
+
+
+
Parameters:
theParent - Object
theProperties - OscProperties
+
+
+ +

+OscP5

+
+public OscP5(Object theParent,
+             String theAddress,
+             int thePort,
+             int theMode)
+
+
+
Parameters:
theParent - Object
theAddress - String
thePort - int
theMode - int
+
+
+ +

+OscP5

+
+public OscP5(Object theParent,
+             int theReceiveAtPort,
+             int theMode)
+
+
+
+ +

+OscP5

+
+public OscP5(Object theParent,
+             int theReceiveAtPort)
+
+
+
Parameters:
theParent - Object
theReceiveAtPort - int
+
+
+ +

+OscP5

+
+public OscP5(Object theParent,
+             String theHost,
+             int theSendToPort,
+             int theReceiveAtPort,
+             String theMethodName)
+
+
Deprecated.  +

+

old version of constructor. still in here for backwards compatibility. +

+

+
+ +

+OscP5

+
+public OscP5(Object theParent,
+             String theAddress,
+             int thePort)
+
+
Deprecated.  +

+

+
Parameters:
theParent - Object
theAddress - String
thePort - int
+
+ + + + + + + + +
+Method Detail
+ +

+version

+
+public String version()
+
+
get the current version of oscP5. +

+

+
+
+
+ +
Returns:
String
+
+
+
+ +

+dispose

+
+public void dispose()
+
+
+
+
+
+
+
+
+
+ +

+addListener

+
+public void addListener(OscEventListener theListener)
+
+
+
+
+
+
+
+
+
+ +

+removeListener

+
+public void removeListener(OscEventListener theListener)
+
+
+
+
+
+
+
+
+
+ +

+listeners

+
+public Vector<OscEventListener> listeners()
+
+
+
+
+
+
+
+
+
+ +

+plug

+
+public void plug(Object theObject,
+                 String theMethodName,
+                 String theAddrPattern,
+                 String theTypeTag)
+
+
osc messages can be automatically forwarded to a specific method of an object. the plug + method can be used to by-pass parsing raw osc messages - this job is done for you with the + plug mechanism. you can also use the following array-types int[], float[], String[]. (but + only as on single parameter e.g. somemethod(int[] theArray) {} ). +

+

+
+
+
+
Parameters:
theObject - Object, can be any Object
theMethodName - String, the method name an osc message should be forwarded to
theAddrPattern - String, the address pattern of the osc message
theTypeTag - String +
+Example
/**
+ * oscP5plug by andreas schlegel
+ * example shows how to use the plug service with oscP5.
+ * the concept of the plug service is, that you can
+ * register methods in your sketch to which incoming 
+ * osc messages will be forwareded automatically without 
+ * having to parse them in the oscEvent method.
+ * that a look at the example below to get an understanding
+ * of how plug works.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+  
+  /* osc plug service
+   * osc messages with a specific address pattern can be automatically
+   * forwarded to a specific method of an object. in this example 
+   * a message with address pattern /test will be forwarded to a method
+   * test(). below the method test takes 2 arguments - 2 ints. therefore each
+   * message with address pattern /test and typetag ii will be forwarded to
+   * the method test(int theA, int theB)
+   */
+  oscP5.plug(this,"test","/test");
+}
+
+
+public void test(int theA, int theB) {
+  println("### plug event method. received a message /test.");
+  println(" 2 ints received: "+theA+", "+theB);  
+}
+
+
+void draw() {
+  background(0);
+}
+
+
+void mousePressed() {
+  /* createan osc message with address pattern /test */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(456); /* add a second int to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+  /* with theOscMessage.isPlugged() you check if the osc message has already been
+   * forwarded to a plugged method. if theOscMessage.isPlugged()==true, it has already 
+   * been forwared to another method in your sketch. theOscMessage.isPlugged() can 
+   * be used for double posting but is not required.
+  */  
+  if(theOscMessage.isPlugged()==false) {
+  /* print the address pattern and the typetag of the received OscMessage */
+  println("### received an osc message.");
+  println("### addrpattern\t"+theOscMessage.addrPattern());
+  println("### typetag\t"+theOscMessage.typetag());
+  }
+}
+
+
+
+
+ +

+plug

+
+public void plug(Object theObject,
+                 String theMethodName,
+                 String theAddrPattern)
+
+
+
+
+
+
Parameters:
theObject - Object, can be any Object
theMethodName - String, the method name an osc message should be forwarded to
theAddrPattern - String, the address pattern of the osc message +
+Example
/**
+ * oscP5plug by andreas schlegel
+ * example shows how to use the plug service with oscP5.
+ * the concept of the plug service is, that you can
+ * register methods in your sketch to which incoming 
+ * osc messages will be forwareded automatically without 
+ * having to parse them in the oscEvent method.
+ * that a look at the example below to get an understanding
+ * of how plug works.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+  
+  /* osc plug service
+   * osc messages with a specific address pattern can be automatically
+   * forwarded to a specific method of an object. in this example 
+   * a message with address pattern /test will be forwarded to a method
+   * test(). below the method test takes 2 arguments - 2 ints. therefore each
+   * message with address pattern /test and typetag ii will be forwarded to
+   * the method test(int theA, int theB)
+   */
+  oscP5.plug(this,"test","/test");
+}
+
+
+public void test(int theA, int theB) {
+  println("### plug event method. received a message /test.");
+  println(" 2 ints received: "+theA+", "+theB);  
+}
+
+
+void draw() {
+  background(0);
+}
+
+
+void mousePressed() {
+  /* createan osc message with address pattern /test */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+  myMessage.add(456); /* add a second int to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+  /* with theOscMessage.isPlugged() you check if the osc message has already been
+   * forwarded to a plugged method. if theOscMessage.isPlugged()==true, it has already 
+   * been forwared to another method in your sketch. theOscMessage.isPlugged() can 
+   * be used for double posting but is not required.
+  */  
+  if(theOscMessage.isPlugged()==false) {
+  /* print the address pattern and the typetag of the received OscMessage */
+  println("### received an osc message.");
+  println("### addrpattern\t"+theOscMessage.addrPattern());
+  println("### typetag\t"+theOscMessage.typetag());
+  }
+}
+
+
+
+
+ +

+process

+
+public void process(DatagramPacket thePacket,
+                    int thePort)
+
+
incoming osc messages from an udp socket are parsed, processed and forwarded to the parent. +

+

+
Specified by:
process in interface UdpPacketListener
+
+
+
Parameters:
thePacket - DatagramPacket
thePort - int
+
+
+
+ +

+process

+
+public void process(TcpPacket thePacket,
+                    int thePort)
+
+
+
Specified by:
process in interface TcpPacketListener
+
+
+
See Also:
TcpPacketListener.process(netP5.TcpPacket, int)
+
+
+
+ +

+remove

+
+public void remove(AbstractTcpClient theTcpClient)
+
+
+
Specified by:
remove in interface TcpPacketListener
+
+
+
Parameters:
theTcpClient - AbstractTcpClient
+
+
+
+ +

+status

+
+public void status(int theIndex)
+
+
+
Specified by:
status in interface TcpPacketListener
+
+
+
Parameters:
theIndex - int
+
+
+
+ +

+properties

+
+public OscProperties properties()
+
+
returns the current properties of oscP5. +

+

+
+
+
+ +
Returns:
OscProperties
+
+
+
+ +

+isBroadcast

+
+public boolean isBroadcast()
+
+
+
+
+
+ +
Returns:
boolean
+
+
+
+ +

+ip

+
+public String ip()
+
+
+
+
+
+ +
Returns:
String
+
+
+
+ +

+setLogStatus

+
+public static void setLogStatus(int theIndex,
+                                int theValue)
+
+
oscP5 has a logging mechanism which prints out processes, warnings and errors into the + console window. e.g. turn off the error log with setLogStatus(Logger.ERROR, Logger.OFF); +

+

+
+
+
+
Parameters:
theIndex - int
theValue - int
+
+
+
+ +

+setLogStatus

+
+public static void setLogStatus(int theValue)
+
+
+
+
+
+
Parameters:
theValue -
+
+
+
+ +

+setTimeToLive

+
+public void setTimeToLive(int theTTL)
+
+
set timeToLive of a multicast packet. +

+

+
+
+
+
Parameters:
theTTL - int
+
+
+
+ +

+disconnect

+
+public void disconnect(NetAddress theHost)
+
+
+
+
+
+
Parameters:
theHost - NetAddress
+
+
+
+ +

+connect

+
+public void connect(NetAddress theNetAddress,
+                    String theName,
+                    String[] theArguments)
+
+
+
+
+
+
Parameters:
theNetAddress - NetAddress
theName - String
theArguments - String[]
+
+
+
+ +

+netInfo

+
+public NetInfo netInfo()
+
+
netinfo() returns an instance of a NetInfo Object from which you can get LAN and WAN + information. +

+

+
+
+
+ +
Returns:
NetInfo
+
+
+
+ +

+tcpServer

+
+public TcpServer tcpServer()
+
+
return the instance of the running TCP server if in TCP mode. +

+

+
+
+
+ +
Returns:
TcpServer
+
+
+
+ +

+tcpClient

+
+public TcpClient tcpClient()
+
+
return the instance of the running TCP client if in TCP mode. +

+

+
+
+
+ +
Returns:
TcpClient
+
+
+
+ +

+send

+
+public void send(OscPacket thePacket,
+                 NetAddress theNetAddress)
+
+
you can send osc packets in many different ways. see below and use the send method that fits + your needs. +

+

+
+
+
+
Parameters:
thePacket - OscPacket
theNetAddress - NetAddress
+
+
+
+ +

+send

+
+public void send(OscPacket thePacket)
+
+
+
+
+
+
Parameters:
thePacket - OscPacket +
+Example
/**
+ * oscP5sendreceive by andreas schlegel
+ * example shows how to send and receive osc messages.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+ 
+import oscP5.*;
+import netP5.*;
+  
+OscP5 oscP5;
+NetAddress myRemoteLocation;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* start oscP5, listening for incoming messages at port 12000 */
+  oscP5 = new OscP5(this,12000);
+  
+  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
+   * an ip address and a port number. myRemoteLocation is used as parameter in
+   * oscP5.send() when sending osc packets to another computer, device, 
+   * application. usage see below. for testing purposes the listening port
+   * and the port of the remote location address are the same, hence you will
+   * send messages back to this sketch.
+   */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+
+void draw() {
+  background(0);  
+}
+
+void mousePressed() {
+  /* in the following different ways of creating osc messages are shown by example */
+  OscMessage myMessage = new OscMessage("/test");
+  
+  myMessage.add(123); /* add an int to the osc message */
+
+  /* send the message */
+  oscP5.send(myMessage, myRemoteLocation); 
+}
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+  /* print the address pattern and the typetag of the received OscMessage */
+  print("### received an osc message.");
+  print(" addrpattern: "+theOscMessage.addrPattern());
+  println(" typetag: "+theOscMessage.typetag());
+}
+
+
+
+
+ +

+send

+
+public void send(OscPacket thePacket,
+                 NetAddressList theNetAddressList)
+
+
+
+
+
+
Parameters:
thePacket - OscPacket
theNetAddressList - NetAddressList
+
+
+
+ +

+send

+
+public void send(String theAddrPattern,
+                 Object[] theArguments)
+
+
+
+
+
+
Parameters:
theAddrPattern - String
theArguments - Object[]
+
+
+
+ +

+send

+
+public void send(String theAddrPattern,
+                 Object[] theArguments,
+                 NetAddressList theNetAddressList)
+
+
+
+
+
+
Parameters:
theAddrPattern - String
theArguments - Object[]
theNetAddressList - NetAddressList
+
+
+
+ +

+send

+
+public void send(String theAddrPattern,
+                 Object[] theArguments,
+                 NetAddress theNetAddress)
+
+
+
+
+
+
Parameters:
theAddrPattern - String
theArguments - Object[]
theNetAddress - NetAddress
+
+
+
+ +

+send

+
+public void send(String theAddrPattern,
+                 Object[] theArguments,
+                 String theAddress,
+                 int thePort)
+
+
+
+
+
+
Parameters:
theAddrPattern - String
theArguments - Object[]
theNetAddress - NetAddress
+
+
+
+ +

+send

+
+public void send(OscPacket thePacket,
+                 TcpClient theClient)
+
+
send to tcp client +

+

+
+
+
+
Parameters:
thePacket - OscPacket
theClient - TcpClient
+
+
+
+ +

+send

+
+public void send(String theAddrPattern,
+                 Object[] theArguments,
+                 TcpClient theClient)
+
+
+
+
+
+
Parameters:
theAddrPattern - String
theArguments - Object[]
theClient - TcpClient
+
+
+
+ +

+send

+
+public void send(OscPacket thePacket,
+                 String theIpAddress,
+                 int thePort)
+
+
Deprecated.  +

+

the send method offers a lot of possibilities. have a look at the send documentation. +

+

+
+
+
+
Parameters:
thePacket - OscPacket
theIpAddress - String
thePort - int
+
+
+
+ +

+stop

+
+public void stop()
+
+
stop oscP5 and close open Sockets. +

+

+
+
+
+
+
+
+
+ +

+flush

+
+public static void flush(OscMessage theOscMessage,
+                         NetAddress theNetAddress)
+
+
a static method to send an OscMessage straight out of the box without having to instantiate + oscP5. +

+

+
+
+
+
Parameters:
theOscMessage - OscMessage
theNetAddress - NetAddress +
+Example
 /**
+ * oscP5flush by andreas schlegel
+ * example shows how to send osc messages without having to instantiate an oscP5 object.
+ * this can be useful if you are not listening for incoming messages and you
+ * want to avoid to have the additional oscP5 thread running listening for incoming 
+ * message (which you wont need if you are only sending messages).
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+ 
+import oscP5.*;
+import netP5.*;
+
+
+NetAddress myRemoteLocation;
+void setup() {
+  size(400,400);
+  frameRate(25);
+  /* set up a remote location */
+  myRemoteLocation = new NetAddress("127.0.0.1",12000);
+}
+
+
+void draw() {
+  background(0);
+}
+
+
+void mousePressed() {
+  /* create a new OscMessage with an address pattern, in this case /test. */
+  OscMessage myOscMessage = new OscMessage("/test");
+  
+  /* add a value (an integer) to the OscMessage */
+  myOscMessage.add(100);
+  
+  /* send the OscMessage to the remote location. 
+   */
+  OscP5.flush(myOscMessage,myRemoteLocation);
+}
+
+
+
+
+ +

+flush

+
+public static void flush(OscPacket theOscPacket,
+                         NetAddress theNetAddress)
+
+
+
+
+
+
+
+
+
+ +

+flush

+
+public static void flush(String theAddrPattern,
+                         Object[] theArguments,
+                         NetAddress theNetAddress)
+
+
+
+
+
+
+
+
+
+ +

+flush

+
+public static void flush(byte[] theBytes,
+                         NetAddress theNetAddress)
+
+
+
+
+
+
+
+
+
+ +

+flush

+
+public static void flush(byte[] theBytes,
+                         String theAddress,
+                         int thePort)
+
+
Deprecated.  +

+

+
+
+
+
Parameters:
theBytes - byte[]
theAddress - String
thePort - int
+
+
+
+ +

+flush

+
+public static void flush(OscMessage theOscMessage,
+                         String theAddress,
+                         int thePort)
+
+
Deprecated.  +

+

+
+
+
+
Parameters:
theOscMessage - OscMessage
theAddress - String
thePort - int
+
+
+
+ +

+newMsg

+
+public OscMessage newMsg(String theAddrPattern)
+
+
Deprecated.  +

+

+
+
+
+
Parameters:
theAddrPattern - String +
Returns:
OscMessage
+
+
+
+ +

+newBundle

+
+public OscBundle newBundle()
+
+
Deprecated.  +

+

+
+
+
+
Parameters:
theAddrPattern - String +
Returns:
OscMessage
+
+
+
+ +

+disconnectFromTEMP

+
+public void disconnectFromTEMP()
+
+
Deprecated.  +

+

used by the monome library by jklabs +

+

+
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/OscPacket.html b/libraries/oscP5/reference/oscP5/OscPacket.html new file mode 100644 index 0000000..18709af --- /dev/null +++ b/libraries/oscP5/reference/oscP5/OscPacket.html @@ -0,0 +1,357 @@ + + + + + + +OscPacket (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +oscP5 +
+Class OscPacket

+
+java.lang.Object
+  extended by oscP5.OscPatcher
+      extended by oscP5.OscPacket
+
+
+
Direct Known Subclasses:
OscBundle, OscMessage
+
+
+
+
public abstract class OscPacket
extends OscPatcher
+ + +

+


+ +

+ + + + + + + + + + + +
+Constructor Summary
OscPacket() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ Stringaddress() + +
+           
+abstract  byte[]getBytes() + +
+           
+ NetAddressnetaddress() + +
+          Deprecated.  
+ NetAddressnetAddress() + +
+           
+ intport() + +
+           
+ TcpClienttcpConnection() + +
+          when in TCP mode, tcpConnection() returns the instance of the TcpClient that has sent the OscMessage.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Constructor Detail
+ +

+OscPacket

+
+public OscPacket()
+
+
+ + + + + + + + +
+Method Detail
+ +

+tcpConnection

+
+public TcpClient tcpConnection()
+
+
when in TCP mode, tcpConnection() returns the instance of the TcpClient that has sent the OscMessage. +

+

+ +
Returns:
TcpClient
+
+
+
+ +

+port

+
+public int port()
+
+
+
+
+
+
+ +

+netAddress

+
+public NetAddress netAddress()
+
+
+
+
+
+
+ +

+netaddress

+
+public NetAddress netaddress()
+
+
Deprecated.  +

+

+ +
Returns:
NetAddress
+
+
+
+ +

+address

+
+public String address()
+
+
+ +
Returns:
String
+
+
+
+ +

+getBytes

+
+public abstract byte[] getBytes()
+
+
+ +
Returns:
byte[]
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/OscPatcher.html b/libraries/oscP5/reference/oscP5/OscPatcher.html new file mode 100644 index 0000000..46ef6d8 --- /dev/null +++ b/libraries/oscP5/reference/oscP5/OscPatcher.html @@ -0,0 +1,192 @@ + + + + + + +OscPatcher (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +oscP5 +
+Class OscPatcher

+
+java.lang.Object
+  extended by oscP5.OscPatcher
+
+
+
Direct Known Subclasses:
OscPacket
+
+
+
+
public abstract class OscPatcher
extends Object
+ + +

+


+ +

+ + + + + + + + +
+Method Summary
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ +


+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/OscPlug.html b/libraries/oscP5/reference/oscP5/OscPlug.html new file mode 100644 index 0000000..94827cb --- /dev/null +++ b/libraries/oscP5/reference/oscP5/OscPlug.html @@ -0,0 +1,393 @@ + + + + + + +OscPlug (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +oscP5 +
+Class OscPlug

+
+java.lang.Object
+  extended by oscP5.OscPlug
+
+
+
+
public class OscPlug
extends Object
+ + +

+


+ +

+ + + + + + + + + + + +
+Field Summary
+ Methodmethod + +
+           
+  + + + + + + + + + + +
+Constructor Summary
OscPlug() + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ booleancheckMethod(OscMessage theOscMessage, + boolean isArray) + +
+           
+ StringcheckType(String theName) + +
+           
+ MethodgetMethod() + +
+           
+ ObjectgetObject() + +
+           
+ voidplug(Object theObject, + String theMethodName, + String theAddrPattern) + +
+           
+ voidplug(Object theObject, + String theMethodName, + String theAddrPattern, + String theTypetag) + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+method

+
+public Method method
+
+
+
+
+ + + + + + + + +
+Constructor Detail
+ +

+OscPlug

+
+public OscPlug()
+
+
+ + + + + + + + +
+Method Detail
+ +

+plug

+
+public void plug(Object theObject,
+                 String theMethodName,
+                 String theAddrPattern)
+
+
+
+
+
+
+ +

+plug

+
+public void plug(Object theObject,
+                 String theMethodName,
+                 String theAddrPattern,
+                 String theTypetag)
+
+
+
+
+
+
+ +

+getObject

+
+public Object getObject()
+
+
+
+
+
+
+ +

+checkMethod

+
+public boolean checkMethod(OscMessage theOscMessage,
+                           boolean isArray)
+
+
+
+
+
+
+ +

+getMethod

+
+public Method getMethod()
+
+
+
+
+
+
+ +

+checkType

+
+public String checkType(String theName)
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/OscProperties.html b/libraries/oscP5/reference/oscP5/OscProperties.html new file mode 100644 index 0000000..21dc5d3 --- /dev/null +++ b/libraries/oscP5/reference/oscP5/OscProperties.html @@ -0,0 +1,799 @@ + + + + + + +OscProperties (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +oscP5 +
+Class OscProperties

+
+java.lang.Object
+  extended by oscP5.OscProperties
+
+
+
+
public class OscProperties
extends Object
+ + +

+osc properties are used to start oscP5 with more specific settings. + osc properties have to be passed to oscP5 in the constructor when + starting a new instance of oscP5. +

+ +

+

+ +
+Example
/**
+ * oscP5properities by andreas schlegel
+ * example shows how to use osc properties. 
+ * if you need more specific settings for your osc session,
+ * osc properties serves your needs.
+ * oscP5 website at http://www.sojamo.de/oscP5
+ */
+import oscP5.*;
+import netP5.*;
+
+OscP5 oscP5;
+
+void setup() {
+  size(400,400);
+  frameRate(25);
+
+  /* create a new osc properties object */
+  OscProperties properties = new OscProperties();
+  
+  /* set a default NetAddress. sending osc messages with no NetAddress parameter 
+   * in oscP5.send() will be sent to the default NetAddress.
+   */
+  properties.setRemoteAddress("127.0.0.1",12000);
+  
+  /* the port number you are listening for incoming osc packets. */
+  properties.setListeningPort(12000);
+  
+  
+  /* Send Receive Same Port is an option where the sending and receiving port are the same.
+   * this is sometimes necessary for example when sending osc packets to supercolider server.
+   * while both port numbers are the same, the receiver can simply send an osc packet back to
+   * the host and port the message came from.
+   */
+  properties.setSRSP(OscProperties.ON);
+  
+  /* set the datagram byte buffer size. this can be useful when you send/receive
+   * huge amounts of data, but keep in mind, that UDP is limited to 64k
+  */
+  properties.setDatagramSize(1024);
+  
+  /* initialize oscP5 with our osc properties */
+  oscP5 = new OscP5(this,properties);    
+  
+  /* print your osc properties */
+  println(properties.toString());
+}
+
+
+
+void mousePressed() {
+  /* create a new osc message with address pattern /test */
+  OscMessage myMessage = new  OscMessage("/test");
+  myMessage.add(200);
+  
+  /* send the osc message to the default netAddress, set in the OscProperties above.*/
+  oscP5.send(myMessage);
+}
+
+
+void draw() {
+  background(0);  
+}
+
+
+
+/* incoming osc message are forwarded to the oscEvent method. */
+void oscEvent(OscMessage theOscMessage) {
+  /* print the address pattern and the typetag of the received OscMessage */
+  print("### received an osc message.");
+  print(" addrpattern: "+theOscMessage.addrPattern());
+  println(" typetag: "+theOscMessage.typetag());
+}
+
+
+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static intMULTICAST + +
+           
+static booleanOFF + +
+           
+static booleanON + +
+           
+static intTCP + +
+           
+static intUDP + +
+           
+  + + + + + + + + + + + + + +
+Constructor Summary
OscProperties() + +
+          create a new OscProperties Object.
OscProperties(OscEventListener theParent) + +
+           
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ intdatagramSize() + +
+          returns the current size of the datagram bytebuffer.
+ StringeventMethod() + +
+           
+ Vector<OscEventListener>listeners() + +
+           
+ intlisteningPort() + +
+          returns the port number currently used to receive osc packets.
+ intnetworkProtocol() + +
+          returns the network protocol being used to transmit osc packets.
+ NetAddressremoteAddress() + +
+          returns a NetAddress of the remote host you are sending + osc packets to.
+ booleansendStatus() + +
+           
+ voidsetDatagramSize(int theSize) + +
+          set the size of the datagrampacket byte buffer.
+ voidsetEventMethod(String theEventMethod) + +
+          set the name of the default event method.
+ voidsetListeningPort(int thePort) + +
+          set port number you are listening for incoming osc packets.
+ voidsetNetworkProtocol(int theProtocol) + +
+          set the network protocol over which osc messages are transmitted.
+ voidsetRemoteAddress(NetAddress theNetAddress) + +
+          set the remote host address.
+ voidsetRemoteAddress(String theHostAddress, + int thePort) + +
+          set the remote host address.
+ voidsetSRSP(boolean theFlag) + +
+          SRSP stand for Send and Receive on Same Port.
+ booleansrsp() + +
+          you can send and receive at the same port while on a udp con
+ StringtoString() + +
+          prints out the current osc properties settings.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+ON

+
+public static final boolean ON
+
+
+
See Also:
Constant Field Values
+
+
+ +

+OFF

+
+public static final boolean OFF
+
+
+
See Also:
Constant Field Values
+
+
+ +

+UDP

+
+public static final int UDP
+
+
+
See Also:
Constant Field Values
+
+
+ +

+MULTICAST

+
+public static final int MULTICAST
+
+
+
See Also:
Constant Field Values
+
+
+ +

+TCP

+
+public static final int TCP
+
+
+
See Also:
Constant Field Values
+
+ + + + + + + + +
+Constructor Detail
+ +

+OscProperties

+
+public OscProperties(OscEventListener theParent)
+
+
+
+ +

+OscProperties

+
+public OscProperties()
+
+
create a new OscProperties Object. +

+

+ + + + + + + + +
+Method Detail
+ +

+listeners

+
+public Vector<OscEventListener> listeners()
+
+
+ +
Returns:
OscEventListener
+
+
+
+ +

+sendStatus

+
+public boolean sendStatus()
+
+
+ +
Returns:
boolean
+
+
+
+ +

+setRemoteAddress

+
+public void setRemoteAddress(String theHostAddress,
+                             int thePort)
+
+
set the remote host address. set ip address and port of the host + message should be sent to. +

+

+
Parameters:
theHostAddress - String
thePort - int
+
+
+
+ +

+setRemoteAddress

+
+public void setRemoteAddress(NetAddress theNetAddress)
+
+
set the remote host address. set ip address and port of the host + message should be sent to. +

+

+
Parameters:
theNetAddress - NetAddress
+
+
+
+ +

+setListeningPort

+
+public void setListeningPort(int thePort)
+
+
set port number you are listening for incoming osc packets. +

+

+
Parameters:
thePort - int
+
+
+
+ +

+setDatagramSize

+
+public void setDatagramSize(int theSize)
+
+
set the size of the datagrampacket byte buffer. + the default size is 1536 bytes. +

+

+
Parameters:
theSize - int
+
+
+
+ +

+setEventMethod

+
+public void setEventMethod(String theEventMethod)
+
+
set the name of the default event method. + the event method is the method to which incoming osc messages + are forwarded. the default name for the event method is + "oscEvent" +

+

+
Parameters:
theEventMethod - String
+
+
+
+ +

+setNetworkProtocol

+
+public void setNetworkProtocol(int theProtocol)
+
+
set the network protocol over which osc messages are transmitted. + options are OscProperties.UDP and OscProperties.MULTICAST + the network protocol can only be set before initializing + oscP5. +

+

+
Parameters:
theProtocol - int
+
+
+
+ +

+setSRSP

+
+public void setSRSP(boolean theFlag)
+
+
SRSP stand for Send and Receive on Same Port. + by default osc packets are not received and sent by the same port. + if you need to send and receive on the same port call + setSRSP(OscProperties.ON) +

+

+
Parameters:
theFlag - boolean
+
+
+
+ +

+srsp

+
+public boolean srsp()
+
+
you can send and receive at the same port while on a udp con +

+

+ +
Returns:
boolean
+
+
+
+ +

+listeningPort

+
+public int listeningPort()
+
+
returns the port number currently used to receive osc packets. +

+

+ +
Returns:
int
+
+
+
+ +

+remoteAddress

+
+public NetAddress remoteAddress()
+
+
returns a NetAddress of the remote host you are sending + osc packets to. by default this is null. +

+

+ +
Returns:
NetAddress
+
+
+
+ +

+datagramSize

+
+public int datagramSize()
+
+
returns the current size of the datagram bytebuffer. +

+

+ +
Returns:
int
+
+
+
+ +

+eventMethod

+
+public String eventMethod()
+
+
+ +
Returns:
String
+
+
+
+ +

+networkProtocol

+
+public int networkProtocol()
+
+
returns the network protocol being used to transmit osc packets. returns an int. + 0 (UDP), 1 (MULTICAST), 2 (TCP) +

+

+ +
Returns:
int
+
+
+
+ +

+toString

+
+public String toString()
+
+
prints out the current osc properties settings. +

+

+
Overrides:
toString in class Object
+
+
+ +
Returns:
String
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/OscStatus.html b/libraries/oscP5/reference/oscP5/OscStatus.html new file mode 100644 index 0000000..d0a95b6 --- /dev/null +++ b/libraries/oscP5/reference/oscP5/OscStatus.html @@ -0,0 +1,448 @@ + + + + + + +OscStatus (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+ +

+ +oscP5 +
+Class OscStatus

+
+java.lang.Object
+  extended by oscP5.OscStatus
+
+
+
+
public class OscStatus
extends Object
+ + +

+


+ +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Field Summary
+static intCLIENT_CLOSED + +
+           
+static intCONNECTION_CLOSED + +
+           
+static intCONNECTION_FAILED + +
+           
+static intCONNECTION_REFUSED + +
+           
+static intCONNECTION_TERMINATED + +
+           
+static intDEFAULT + +
+           
+static intERROR + +
+           
+static intOSCP5_CLOSED + +
+           
+static intSEND_FAILED + +
+           
+static intSERVER_CLOSED + +
+           
+  + + + + + + + + + + +
+Constructor Summary
OscStatus(int theIndex) + +
+           
+  + + + + + + + + + + + +
+Method Summary
+ intid() + +
+           
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + +
+Field Detail
+ +

+ERROR

+
+public static int ERROR
+
+
+
+
+
+ +

+DEFAULT

+
+public static int DEFAULT
+
+
+
+
+
+ +

+CONNECTION_CLOSED

+
+public static int CONNECTION_CLOSED
+
+
+
+
+
+ +

+CONNECTION_REFUSED

+
+public static int CONNECTION_REFUSED
+
+
+
+
+
+ +

+CONNECTION_TERMINATED

+
+public static int CONNECTION_TERMINATED
+
+
+
+
+
+ +

+CONNECTION_FAILED

+
+public static int CONNECTION_FAILED
+
+
+
+
+
+ +

+SERVER_CLOSED

+
+public static int SERVER_CLOSED
+
+
+
+
+
+ +

+CLIENT_CLOSED

+
+public static int CLIENT_CLOSED
+
+
+
+
+
+ +

+SEND_FAILED

+
+public static int SEND_FAILED
+
+
+
+
+
+ +

+OSCP5_CLOSED

+
+public static int OSCP5_CLOSED
+
+
+
+
+ + + + + + + + +
+Constructor Detail
+ +

+OscStatus

+
+public OscStatus(int theIndex)
+
+
+ + + + + + + + +
+Method Detail
+ +

+id

+
+public int id()
+
+
+
+
+
+ +
+ + + + + + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/package-frame.html b/libraries/oscP5/reference/oscP5/package-frame.html new file mode 100644 index 0000000..60d3716 --- /dev/null +++ b/libraries/oscP5/reference/oscP5/package-frame.html @@ -0,0 +1,63 @@ + + + + + + +oscP5 (Javadocs: oscP5) + + + + + + + + + + + +oscP5 + + + + +
+Interfaces  + +
+OscEventListener
+ + + + + + +
+Classes  + +
+OscArgument +
+OscBundle +
+OscIn +
+OscMessage +
+OscNetManager +
+OscP5 +
+OscPacket +
+OscPatcher +
+OscPlug +
+OscProperties +
+OscStatus
+ + + + diff --git a/libraries/oscP5/reference/oscP5/package-summary.html b/libraries/oscP5/reference/oscP5/package-summary.html new file mode 100644 index 0000000..38df1fd --- /dev/null +++ b/libraries/oscP5/reference/oscP5/package-summary.html @@ -0,0 +1,211 @@ + + + + + + +oscP5 (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+

+Package oscP5 +

+ + + + + + + + + +
+Interface Summary
OscEventListener 
+  + +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Class Summary
OscArgumentan osc argument contains one value of values from a received osc message.
OscBundleOsc Bundles are collections of Osc Messages.
OscInDeprecated.
OscMessageAn OSC message consists of an OSC Address Pattern, an OSC Type Tag String + and the OSC arguments.
OscNetManager 
OscP5TODO add better error message handling for oscEvents, see this post + http://forum.processing.org/topic/oscp5-major-problems-with-error-handling# 25080000000811163
OscPacket 
OscPatcher 
OscPlug 
OscPropertiesosc properties are used to start oscP5 with more specific settings.
OscStatus 
+  + +

+

+
+
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/oscP5/package-tree.html b/libraries/oscP5/reference/oscP5/package-tree.html new file mode 100644 index 0000000..dce25b1 --- /dev/null +++ b/libraries/oscP5/reference/oscP5/package-tree.html @@ -0,0 +1,164 @@ + + + + + + +oscP5 Class Hierarchy (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For Package oscP5 +

+
+
+
Package Hierarchies:
All Packages
+
+

+Class Hierarchy +

+ +

+Interface Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/overview-frame.html b/libraries/oscP5/reference/overview-frame.html new file mode 100644 index 0000000..73a8387 --- /dev/null +++ b/libraries/oscP5/reference/overview-frame.html @@ -0,0 +1,44 @@ + + + + + + +Overview List (Javadocs: oscP5) + + + + + + + + + + + + + + + +
+
+ + + + + +
All Classes +

+ +Packages +
+netP5 +
+oscP5 +
+

+ +

+  + + diff --git a/libraries/oscP5/reference/overview-summary.html b/libraries/oscP5/reference/overview-summary.html new file mode 100644 index 0000000..750deeb --- /dev/null +++ b/libraries/oscP5/reference/overview-summary.html @@ -0,0 +1,158 @@ + + + + + + +Overview (Javadocs: oscP5) + + + + + + + + + + + + +


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Javadocs: oscP5 +

+
+ + + + + + + + + + + + + +
+Packages
netP5 
oscP5 
+ +


+ + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/overview-tree.html b/libraries/oscP5/reference/overview-tree.html new file mode 100644 index 0000000..629494a --- /dev/null +++ b/libraries/oscP5/reference/overview-tree.html @@ -0,0 +1,179 @@ + + + + + + +Class Hierarchy (Javadocs: oscP5) + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+
+

+Hierarchy For All Packages

+
+
+
Package Hierarchies:
netP5, oscP5
+
+

+Class Hierarchy +

+ +

+Interface Hierarchy +

+ +
+ + + + + + + + + + + + + + + +
+ +
+ + + +
+processing library oscP5 by Andreas Schlegel. (c) 2004-2012 + + diff --git a/libraries/oscP5/reference/package-list b/libraries/oscP5/reference/package-list new file mode 100644 index 0000000..145784b --- /dev/null +++ b/libraries/oscP5/reference/package-list @@ -0,0 +1,2 @@ +netP5 +oscP5 diff --git a/libraries/oscP5/reference/resources/inherit.gif b/libraries/oscP5/reference/resources/inherit.gif new file mode 100644 index 0000000..c814867 Binary files /dev/null and b/libraries/oscP5/reference/resources/inherit.gif differ diff --git a/libraries/oscP5/reference/stylesheet.css b/libraries/oscP5/reference/stylesheet.css new file mode 100644 index 0000000..54998c2 --- /dev/null +++ b/libraries/oscP5/reference/stylesheet.css @@ -0,0 +1,310 @@ +/* Javadoc style sheet */ +/* Define colors, fonts and other style attributes here to override the defaults */ +/* processingLibs style by andreas schlegel, sojamo */ + + +body { + margin : 0; + padding : 0; + padding-left : 10px; + padding-right : 8px; + background-color : #FFFFFF; + font-family : Verdana, Geneva, Arial, Helvetica, sans-serif; + font-size : 100%; + font-size : 0.7em; + font-weight : normal; + line-height : normal; + margin-bottom:30px; +} + + + + +/* Headings */ +h1, h2, h3, h4, h5, th { + font-family :Arial, Helvetica, sans-serif; + font-size:1.2em; +} + + +p { + font-size : 1em; + width:80%; +} + +pre, code { + font-family : "Courier New", Courier, monospace; + font-size : 12px; + line-height : normal; +} + + + +table { + border:0; + margin-bottom:10px; + margin-top:10px; +} + + +tr, td { + border-top: 0px solid; + border-left: 0px solid; + padding-top:8px; + padding-bottom:8px; +} + + + +hr { + border:0; + height:1px; + padding:0; + margin:0; + margin-bottom:4px; + +} + + + +dd, th, td, font { + font-size:1.0em; + line-height:1.0em; +} + + + +dt { + margin-bottom:0px; +} + + + +dd { + margin-top:2px; + margin-bottom:4px; +} + + + +a { + text-decoration: underline; + font-weight: normal; +} + +a:hover, +a:active { + text-decoration: underline; + font-weight: normal; +} + +a:visited, +a:link:visited { + text-decoration: underline; + font-weight: normal; +} + + +img { + border: 0px solid #000000; +} + + + +/* Navigation bar fonts */ +.NavBarCell1 { + border:0; +} + +.NavBarCell1Rev { + border:0; +} + +.NavBarFont1 { + font-family: Arial, Helvetica, sans-serif; + font-size:1.1em; +} + + +.NavBarFont1 b { + font-weight:normal; +} + + + +.NavBarFont1:after, .NavBarFont1Rev:after { + font-weight:normal; + content: " \\"; +} + + +.NavBarFont1Rev { + font-family: Arial, Helvetica, sans-serif; + font-size:1.1em; +} + +.NavBarFont1Rev b { + font-family: Arial, Helvetica, sans-serif; + font-size:1.1em; + font-weight:normal; +} + +.NavBarCell2 { + font-family: Arial, Helvetica, sans-serif; +} + +.NavBarCell3 { + font-family: Arial, Helvetica, sans-serif; +} + + + +font.FrameItemFont { + font-family: Helvetica, Arial, sans-serif; + font-size:1.1em; + line-height:1.1em; +} + +font.FrameHeadingFont { + font-family: Helvetica, Arial, sans-serif; + line-height:32px; +} + +/* Font used in left-hand frame lists */ +.FrameTitleFont { + font-family: Helvetica, Arial, sans-serif +} + + +.toggleList { + padding:0; + margin:0; + margin-top:12px; +} + +.toggleList dt { + font-weight:bold; + font-size:12px; + font-family:arial,sans-serif; + padding:0px; + margin:10px 0px 10px 0px; +} + +.toggleList dt span { + font-family: monospace; + padding:0; + margin:0; +} + + +.toggleList dd { + margin:0; + padding:0; +} + +html.isjs .toggleList dd { + display: none; +} + +.toggleList pre { + padding: 4px 4px 4px 4px; +} + + + + + +/* COLORS */ + +pre, code { + color: #000000; +} + + +body { + color : #333333; + background-color :#FFFFFF; +} + + +h1, h2, h3, h4, h5, h6 { + color:#555; +} + +a, +.toggleList dt { + color: #1a7eb0; +} + +a:hover, +a:active { + color: #1a7eb0; +} + +a:visited, +a:link:visited { + color: #1a7eb0; +} + +td,tr { + border-color: #999999; +} + +hr { + color:#999999; + background:#999999; +} + + +.TableHeadingColor { + background: #dcdcdc; + color: #555; +} + + +.TableSubHeadingColor { + background: #EEEEFF +} + +.TableRowColor { + background: #FFFFFF +} + + +.NavBarCell1 { + background-color:#dcdcdc; + color:#000; +} + +.NavBarCell1 a { + color:#333; +} + + +.NavBarCell1Rev { + background-color:transparent; +} + +.NavBarFont1 { + color:#333; +} + + +.NavBarFont1Rev { + color:#fff; +} + +.NavBarCell2 { + background-color:#999; +} + +.NavBarCell2 a { + color:#fff; +} + + + +.NavBarCell3 { + background-color:#dcdcdc; +} + diff --git a/libraries/oscP5/src/netP5/AbstractMulticast.java b/libraries/oscP5/src/netP5/AbstractMulticast.java new file mode 100644 index 0000000..6a85451 --- /dev/null +++ b/libraries/oscP5/src/netP5/AbstractMulticast.java @@ -0,0 +1,337 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +import java.io.IOException; + +import java.net.MulticastSocket; +import java.net.SocketException; +import java.net.DatagramPacket; +import java.util.Vector; + +/** + * @invisible + */ +public abstract class AbstractMulticast implements Runnable { + + protected NetAddress _myNetAddress; + + protected boolean isRunning; + + protected boolean isSocket; + + protected MulticastSocket _myMulticastSocket; + + protected UdpPacketListener _myListener; + + protected int _myDatagramSize = 1536; + + private Thread _myThread; + + + /** + * @invisible + * @param theDatagramListener UdpPacketListener + * @param theMulticastAddress String + * @param thePort int + * @param theBufferSize int + */ + public AbstractMulticast( + final UdpPacketListener theDatagramListener, + final String theMulticastAddress, + final int thePort, + final int theBufferSize) { + _myDatagramSize = theBufferSize; + _myListener = theDatagramListener; + if (_myListener != null) { + init(theMulticastAddress, thePort); + } + } + + /** + * @invisible + * @param theDatagramListener UdpPacketListener + * @param theMulticastAddress String + * @param thePort int + */ + public AbstractMulticast( + final UdpPacketListener theDatagramListener, + final String theMulticastAddress, + final int thePort) { + _myListener = theDatagramListener; + if (_myListener != null) { + init(theMulticastAddress, thePort); + } + } + + protected void init(final String theMulticastAddress, final int thePort) { + _myNetAddress = new NetAddress(theMulticastAddress, thePort); + if (!_myNetAddress.isvalid()) { + Logger.printError("UdpClient", "unknown host " + + theMulticastAddress); + } + isRunning = openSocket(); + start(); + } + + + /** + * get the running multicast socket. + * @return MulticastSocket + */ + public MulticastSocket socket() { + return _myMulticastSocket; + } + + /** + * set the buffer size of the datagrams received by the multicast socket. + * @param theDatagramSize int + */ + public void setDatagramSize(int theDatagramSize) { + _myDatagramSize = theDatagramSize; + } + + /** + * @invisible + */ + public void start() { + _myThread = null; + _myMulticastSocket = null; + _myThread = new Thread(this); + try { + Thread.sleep(1000); + } catch (InterruptedException iex) { + Logger.printError("Multicast.start()", + "Multicast sleep interuption " + iex); + } + try { + _myMulticastSocket = new MulticastSocket(_myNetAddress.port()); + _myMulticastSocket.joinGroup(_myNetAddress.inetaddress()); + Logger.printProcess("Multicast.start()", + "new Multicast DatagramSocket created @ port " + + _myNetAddress.port()); + } catch (IOException ioex) { + Logger.printError("Multicast.start()", + " IOException, couldnt create new DatagramSocket @ port " + + _myNetAddress.port() + " " + ioex); + } + if (_myMulticastSocket != null) { + _myThread.start(); + isRunning = _myThread.isAlive(); + isSocket = true; + } else { + isRunning = false; + } + } + + /** + * @invisible + */ + public void run() { + if (_myMulticastSocket != null) { + if (isRunning) { + Logger.printProcess("Multicast.run()", + "Multicast is running @ " + + _myNetAddress.inetaddress().getHostAddress() + + ":" + _myNetAddress.port()); + } + } else { + Logger.printError("UdpServer.run()", + "Socket is null. closing UdpServer."); + return; + } + + while (isRunning) { + try { + byte[] myBuffer = new byte[_myDatagramSize]; + DatagramPacket myPacket = new DatagramPacket(myBuffer, + _myDatagramSize); + _myMulticastSocket.receive(myPacket); + Logger.printDebug("Multicast.run()","got it."); + _myListener.process(myPacket, _myNetAddress.port()); + } catch (IOException ioex) { + Logger.printError("UdpServer.run()", "IOException: " + ioex); + break; + } catch (ArrayIndexOutOfBoundsException ex) { + Logger.printError("UdpServer.run()", + "ArrayIndexOutOfBoundsException: " + ex); + } + } + dispose(); + } + + /** + * dispose the multicastSocket. + */ + public void dispose() { + close(); + } + + /** + * @invisible + */ + public void close() { + isRunning = false; + if (_myMulticastSocket != null) { + try { + _myMulticastSocket.leaveGroup(_myNetAddress.inetaddress()); + _myMulticastSocket.disconnect(); + _myMulticastSocket.close(); + _myMulticastSocket = null; + Logger.printProcess("Multicast.close", + "Closing multicast datagram socket."); + } catch (IOException e) { + + } + } + } + + private boolean openSocket() { + try { + _myMulticastSocket = new MulticastSocket(); + } catch (SocketException e) { + Logger.printError("Multicast.openSocket", "cant create socket " + + e.getMessage()); + return false; + } catch (IOException e) { + Logger.printError("Multicast.openSocket", + "cant create multicastSocket " + e.getMessage()); + return false; + } + Logger.printProcess("Multicast.openSocket", + "multicast socket initialized."); + return true; + } + + /** + * Set the default time-to-live for multicast packets + * sent out on this MulticastSocket in order to control the scope + * of the multicasts. theTTL must be in the range 0 <= ttl <= 255 + * @param theTTL int + * @return boolean + * @shortdesc Set the default time-to-live for multicast packets. + */ + public boolean setTimeToLive(int theTTL) { + try { + _myMulticastSocket.setTimeToLive(theTTL); + return true; + } catch (IOException ioe) { + Logger.printError("UdpServer.setTimeToLive()", "" + ioe); + } catch (IllegalArgumentException iae) { + Logger.printError("UdpServer.setTimeToLive()", "" + iae); + } + return false; + } + + /** + * get the current time to live value. + * + * @return int + */ + public int timeToLive() { + try { + return _myMulticastSocket.getTimeToLive(); + } catch (IOException ioe) { + Logger.printError("Multicast.getTimeToLive()", "" + ioe); + } + return -1; + } + + /** + * Disable/Enable local loopback of multicast datagrams. + * The option is used by the platform's networking code as a + * hint for setting whether multicast data will be + * looped back to the local socket. + * @shortdesc Disable/Enable local loopback of multicast datagrams. + * @param theFlag boolean + */ + public void setLoopback(boolean theFlag) { + try { + _myMulticastSocket.setLoopbackMode(theFlag); + } catch (SocketException se) { + Logger.printError("Multicast.setLoopback()", "" + se); + } + } + + /** + * get the current loopback mode. messages loop back to the local address + * if the loopback is set to false. set loopback to false to prevent messages + * to loop back to your local address. + * + * @return boolean + * @shortdesc get the current loopback mode. + */ + public boolean loopback() { + try { + return _myMulticastSocket.getLoopbackMode(); + } catch (SocketException se) { + Logger.printError("Multicast.loopback()", "" + se); + } + return false; + } + + protected void send(DatagramPacket thePacket) { + if (isRunning) { + try { + _myMulticastSocket.send(thePacket); + + } catch (IOException e) { + Logger.printError("Multicast.send", + "ioexception while sending packet."); + } + } + } + + /** + * send a string to the multicast address. + * @param theString String + */ + public void send(String theString) { + send(theString.getBytes()); + } + + /** + * send a byte array to the mulitcast address. + * @param theBytes byte[] + */ + public void send(byte[] theBytes) { + if (isRunning) { + try { + DatagramPacket myPacket = new DatagramPacket(theBytes, + theBytes.length, _myNetAddress.inetaddress(), + _myNetAddress.port()); + send(myPacket); + } catch (NullPointerException npe) { + Logger.printError("Multicast.send", + "a nullpointer exception occured." + npe); + } + } else { + Logger.printWarning("Multicast.send", + "DatagramSocket is not running. Packet has not been sent."); + } + } + +} diff --git a/libraries/oscP5/src/netP5/AbstractTcpClient.java b/libraries/oscP5/src/netP5/AbstractTcpClient.java new file mode 100644 index 0000000..7f6cac4 --- /dev/null +++ b/libraries/oscP5/src/netP5/AbstractTcpClient.java @@ -0,0 +1,491 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintWriter; +import java.net.Socket; +import java.io.InputStream; +import java.io.OutputStream; + + +/** + * @invisible + */ +public abstract class AbstractTcpClient implements Runnable { + + private Socket _mySocket; + + protected TcpPacketListener _myTcpPacketListener; + + private PrintWriter _myOutput = null; + + private BufferedReader _myInput = null; + + private OutputStream _myOutputStream = null; + + protected byte[] _myBytes = new byte[0]; + + protected StringBuffer _myStringBuffer = new StringBuffer(0); + + protected AbstractTcpServer _myTcpServer; + + protected NetAddress _myNetAddress; + + protected int _myServerPort; + + private Thread _myThread; + + private char TERMINATOR = '\0'; + + /** + * terminator is readline. + */ + public static final int MODE_READLINE = 0; + + /** + * terminator is terminated, by default this is character '\0' + * and can be set with setTerminator + */ + public static final int MODE_TERMINATED = 1; + + /** + * terminator is newline. + */ + public static final int MODE_NEWLINE = 2; + + /** + * no terminator required, packets are sent via + * a tcp stream. + */ + public static final int MODE_STREAM = 3; + + private final int _myMode; + + /** + * @invisible + * @param theTcpPacketListener TcpPacketListener + * @param theHost String + * @param thePort int + */ + public AbstractTcpClient(final TcpPacketListener theTcpPacketListener, + final String theHost, + final int thePort) { + this(theTcpPacketListener, theHost, thePort, MODE_READLINE); + } + + /** + * @invisible + * @param theHost String + * @param thePort int + */ + public AbstractTcpClient(final String theHost, + final int thePort) { + this(null, theHost, thePort, MODE_READLINE); + } + + /** + * @invisible + * @param theTcpPacketListener TcpPacketListener + * @param theHost String + * @param thePort int + * @param theMode int + */ + public AbstractTcpClient(final TcpPacketListener theTcpPacketListener, + final String theHost, + final int thePort, + final int theMode) { + _myTcpPacketListener = theTcpPacketListener; + _myNetAddress = new NetAddress(theHost, thePort); + _myMode = theMode; + startSocket(); + } + + /** + * @invisible + * @param theHost String + * @param thePort int + * @param theMode int + */ + public AbstractTcpClient(final String theHost, + final int thePort, + final int theMode) { + this(null, theHost, thePort, theMode); + } + + + /** + * @invisible + * @param theTcpServer AbstractTcpServer + * @param theSocket Socket + * @param theTcpPacketListener TcpPacketListener + * @param theServerPort int + * @param theMode int + */ + public AbstractTcpClient(final AbstractTcpServer theTcpServer, + final Socket theSocket, + final TcpPacketListener theTcpPacketListener, + final int theServerPort, + final int theMode) { + _myTcpServer = theTcpServer; + _mySocket = theSocket; + _myTcpPacketListener = theTcpPacketListener; + _myServerPort = theServerPort; + _myMode = theMode; + startSocket(); + } + + + private void startSocket() { + try { + if (_mySocket == null) { + _mySocket = new Socket(_myNetAddress.address(), _myNetAddress.port()); + } else { + _myNetAddress = new NetAddress(_mySocket.getInetAddress().getHostAddress(), + _mySocket.getPort()); + } + Logger.printProcess("TcpClient", "### starting new TcpClient " + _myNetAddress); + if (_myMode == MODE_STREAM) { + _myOutputStream = _mySocket.getOutputStream(); + } + init(); + } catch (final IOException e) { + Logger.printError("TcpClient", + "IOException while trying to create a new socket."); +// handleStatus(NetStatus.CONNECTION_FAILED); // FIX! NetPlug is still null at this point. NetPlug has to exist first. + } + } + + + /** + * when a TCP connection is lost, reconnect to the server with reconnect(). + */ + public void reconnect() { + try { + Thread.sleep(1000); + } catch(final Exception e) { } + startSocket(); + } + + + private void init() { + _myThread = new Thread(this); + _myThread.start(); + } + + /** + * to parse an incomming tcp message, a terminator character is required to + * determine the end of the message so that it can be parsed and forwarded. + * + * @param theTerminator + */ + public void setTerminator(final char theTerminator) { + TERMINATOR = theTerminator; + } + + /** + * stop and dispose a tcp client. + */ + public void dispose() { + try { + // do io streams need to be closed first? + if (_myInput != null) { + _myInput.close(); + } + if (_myOutput != null) { + _myOutput.close(); + } + + } catch (final Exception e) { + e.printStackTrace(); + } + _myInput = null; + _myOutput = null; + + try { + if (_mySocket != null) { + _mySocket.close(); + } + + } catch (final Exception e) { + e.printStackTrace(); + } + if(_myThread==null) { + return; + } + _mySocket = null; + _myThread = null; + handleStatus(NetStatus.CONNECTION_CLOSED); + Logger.printProcess("TcpClient.dispose", "TcpClient closed."); + } + + /** + * @invisible + */ + public void run() { + if (_myMode == MODE_STREAM) { + try { + try { + // sleep a little bit to avoid threading and nullpointer + // issues when reconnecting. + _myThread.sleep(500); + } catch (final Exception e) { + + } + + final InputStream in = _mySocket.getInputStream(); + while (!_mySocket.isClosed() && _mySocket != null) { + final int myLen = Bytes.toIntBigEndian(in); + if (myLen < 0) { + break; + } + _myBytes = Bytes.toByteArray(in, myLen); + handleInput(); + } + } catch (final java.net.SocketException se) { + System.out.println("Connection reset."); + } catch (final Exception e) { + System.out.println("### EXCEPTION " + e); + } + try { + handleStatus(NetStatus.SERVER_CLOSED); + handleStatus(NetStatus.CONNECTION_TERMINATED); + dispose(); + } catch (final NullPointerException e) { + System.out.println("### nullpointer while calling handleStatus."); + } + } else { + while (Thread.currentThread() == _myThread) { + switch (_myMode) { + case (MODE_TERMINATED): + read(); + break; + case (MODE_READLINE): + default: + readline(); + break; + } + break; + } + } + if (_myTcpServer != null) { + _mySocket = null; + _myTcpServer.remove(this); + } + } + + + private void read() { + try { + _myInput = new BufferedReader(new InputStreamReader(_mySocket.getInputStream())); + + final char[] charBuffer = new char[1]; + while (_myInput.read(charBuffer, 0, 1) != -1) { + + /**@todo + * StringBuffer size is limited yet. + * increase the buffer size dynamically. + */ + _myStringBuffer = new StringBuffer(4096); + while (charBuffer[0] != TERMINATOR && charBuffer[0] != 3) { + _myStringBuffer.append(charBuffer[0]); + _myInput.read(charBuffer, 0, 1); + } + _myBytes = _myStringBuffer.toString().getBytes(); + handleInput(); + } + } catch (final IOException e) { + Logger.printProcess("TcpClient.read()", "connection has been terminated."); + if (_myTcpServer == null) { + handleStatus(NetStatus.SERVER_CLOSED); + } + handleStatus(NetStatus.CONNECTION_TERMINATED); + } + } + + + private void readline() { + try { + _myOutput = new PrintWriter(_mySocket.getOutputStream(), true); + _myInput = new BufferedReader(new InputStreamReader(_mySocket.getInputStream())); + String inputLine; + + while ((inputLine = _myInput.readLine()) != null) { + _myStringBuffer = new StringBuffer(inputLine); + _myBytes = _myStringBuffer.toString().getBytes(); + handleInput(); + } + } catch (final IOException e) { + Logger.printProcess("TcpClient.readline()", "connection has been terminated."); + handleStatus(NetStatus.CONNECTION_TERMINATED); + if (_myTcpServer == null) { + handleStatus(NetStatus.SERVER_CLOSED); + } + } + } + + /** + * @invisible + */ + public abstract void handleInput(); + + /** + * @invisible + * @param theIndex + */ + public abstract void handleStatus(int theIndex); + + /** + * @invisible + * @return + */ + public TcpPacketListener listener() { + return _myTcpPacketListener; + } + + /** + * get the server port. + * @return + */ + public int serverport() { + return _myServerPort; + } + + /** + * get the instance of the socket. more info at java.net.Socket + * @return + */ + public Socket socket() { + return _mySocket; + } + + + /** + * get the mode of the terminator. + * @return + */ + public int mode() { + return _myMode; + } + + + public String getString() { + return _myStringBuffer.toString(); + } + + + public StringBuffer getStringBuffer() { + return _myStringBuffer; + } + + + public void send(final byte[] theBytes) { + if (_myMode == MODE_STREAM) { + try { + Bytes.toStream(_myOutputStream, theBytes); + } catch (final Exception ex) { + handleStatus(NetStatus.SEND_FAILED); + } + } else { + System.out.println("### sending bytes is only supported for STREAMs"); + } + } + + + public void send(final byte[][] theBytes) { + if (_myMode == MODE_STREAM) { + try { + for (int i = 0; i < theBytes.length; i++) { + Bytes.toStream(_myOutputStream, theBytes[i]); + } + } catch (final Exception ex) { + handleStatus(NetStatus.SEND_FAILED); + } + } else { + System.out.println("### sending bytes is only supported for STREAMs"); + } + + } + + + public void send(final String theString) { + if (_myMode == MODE_STREAM) { + send(theString.getBytes()); + } else { + switch (_myMode) { + case (MODE_TERMINATED): + _myOutput.write(theString + TERMINATOR); + break; + case (MODE_NEWLINE): + _myOutput.write(theString + "\n"); + break; + case (MODE_READLINE): + default: + _myOutput.println(theString); + break; + } + _myOutput.flush(); + } + } + + + public NetAddress netAddress() { + return _myNetAddress; + } + + + /** + * @deprecated + * @invisible + * @return NetAddress + */ + + public NetAddress netaddress() { + return _myNetAddress; + } + + + /** + * @param theNetAddress NetAddress + * @return boolean + */ + public boolean equals(final NetAddress theNetAddress) { + if (theNetAddress.address().equals(_myNetAddress.address()) && + theNetAddress.port() == _myNetAddress.port()) { + return true; + } + return false; + } + + + public boolean equals(final TcpClient theClient) { + return equals(theClient.netAddress()); + } + +} diff --git a/libraries/oscP5/src/netP5/AbstractTcpServer.java b/libraries/oscP5/src/netP5/AbstractTcpServer.java new file mode 100644 index 0000000..824efbb --- /dev/null +++ b/libraries/oscP5/src/netP5/AbstractTcpServer.java @@ -0,0 +1,317 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +import java.io.IOException; +import java.net.ServerSocket; +import java.util.Enumeration; +import java.util.Vector; + +/** + * @invisible + */ + +public abstract class AbstractTcpServer implements Runnable, TcpPacketListener { + + protected ServerSocket _myServerSocket; + + protected static int _myPort; + + protected TcpPacketListener _myTcpPacketListener = null; + + protected Vector _myTcpClients; + + protected Thread _myThread; + + public final static int MODE_READLINE = TcpClient.MODE_READLINE; + + public final static int MODE_TERMINATED = TcpClient.MODE_TERMINATED; + + public final static int MODE_NEWLINE = TcpClient.MODE_NEWLINE; + + public final static int MODE_STREAM = TcpClient.MODE_STREAM; + + protected final int _myMode; + + protected Vector _myBanList; + + /** + * @invisible + * @param thePort + * int + * @param theMode + * int + */ + public AbstractTcpServer( + final int thePort, + final int theMode) { + _myPort = thePort; + _myMode = theMode; + _myTcpPacketListener = this; + init(); + } + + /** + * @invisible + * @param theTcpPacketListener + * TcpPacketListener + * @param thePort + * int + * @param theMode + * int + */ + public AbstractTcpServer( + final TcpPacketListener theTcpPacketListener, + final int thePort, + final int theMode) { + _myPort = thePort; + _myMode = theMode; + _myTcpPacketListener = theTcpPacketListener; + init(); + } + + protected void init() { + _myBanList = new Vector(); + _myServerSocket = null; + _myTcpClients = new Vector(); + try { + Thread.sleep(1000); + } catch (InterruptedException iex) { + Logger.printError("TcpServer.start()", + "TcpServer sleep interuption " + iex); + return; + } + try { + _myServerSocket = new ServerSocket(_myPort); + } catch (IOException e) { + Logger.printError("TcpServer.start()", "TcpServer io Exception " + + e); + return; + } + + _myThread = new Thread(this); + _myThread.start(); + Logger.printProcess("TcpServer", "ServerSocket started @ " + _myPort); + } + + /** + * ban an IP address from the server. + * @param theIP + */ + public void ban(String theIP) { + _myBanList.add(theIP); + for (int i = _myTcpClients.size() - 1; i >= 0; i--) { + if (((TcpClient) _myTcpClients.get(i)).netAddress().address() + .equals(theIP)) { + ((TcpClient) _myTcpClients.get(i)).dispose(); + } + } + } + + /** + * remove the ban for an IP address. + * @param theIP + */ + public void unBan(String theIP) { + _myBanList.remove(theIP); + } + + + private boolean checkBanList(ServerSocket theSocket) { + try { + String mySocketAddress = theSocket.getInetAddress() + .getHostAddress(); + String mySocketName = theSocket.getInetAddress().getHostName(); + for (int i = _myBanList.size() - 1; i >= 0; i--) { + if (mySocketAddress.equals(_myBanList.get(i)) + || mySocketName.equals(_myBanList.get(i))) { + return false; + } + } + return true; + } catch (Exception e) { + } + return false; + } + + /** + * get the server socket object. more at java.net.ServerSocket + * @return + */ + public ServerSocket socket() { + return _myServerSocket; + } + + /** + * @invisible + */ + public void run() { + threadLoop: while (Thread.currentThread() == _myThread) { + try { + /** + * @author when synchronized, disconnected clients are only + * removed from _myTcpClients when there is a new + * connection. + */ + // synchronized(_myTcpClients) { + if (checkBanList(_myServerSocket)) { + TcpClient t = new TcpClient(this, _myServerSocket.accept(), + _myTcpPacketListener, _myPort, _myMode); + if (NetP5.DEBUG) { + System.out.println("### new Client @ " + t); + } + _myTcpClients.addElement(t); + Logger.printProcess("TcpServer.run", _myTcpClients.size() + + " currently running."); + } + } + // } + catch (IOException e) { + Logger.printError("TcpServer", "IOException. Stopping server."); + break threadLoop; + } + } + dispose(); + } + + /** + * send a string to the connected client(s). + * @param theString + */ + public synchronized void send(final String theString) { + try { + Enumeration en = _myTcpClients.elements(); + while (en.hasMoreElements()) { + ((TcpClient) en.nextElement()).send(theString); + } + } catch (NullPointerException e) { + + } + } + + /** + * send a byte array to the connected client(s). + * @param theBytes + */ + public synchronized void send(final byte[] theBytes) { + try { + Enumeration en = _myTcpClients.elements(); + while (en.hasMoreElements()) { + ((TcpClient) en.nextElement()).send(theBytes); + } + } catch (NullPointerException e) { + + } + } + + /** + * kill the server. + */ + public void dispose() { + try { + _myThread = null; + + if (_myTcpClients != null) { + Enumeration en = _myTcpClients.elements(); + while (en.hasMoreElements()) { + remove((TcpClient) en.nextElement()); + } + _myTcpClients = null; + } + + if (_myServerSocket != null) { + _myServerSocket.close(); + _myServerSocket = null; + } + } catch (IOException e) { + Logger.printError("TcpServer.dispose", "IOException " + e); + } + } + + /** + * get the number of connected clients. + * @return + */ + public int size() { + return _myTcpClients.size(); + } + + /** + * get a list of all connected clients. an array of type TcpClient[] + * will be returned. + * @return + */ + public TcpClient[] getClients() { + TcpClient[] s = new TcpClient[_myTcpClients.size()]; + _myTcpClients.toArray(s); + return s; + } + + /** + * get a client at a specific position the client list. + * @param theIndex + * @return + */ + public TcpClient getClient(final int theIndex) { + return (TcpClient) _myTcpClients.elementAt(theIndex); + } + + /** + * @invisible + * @param thePacket + * TcpPacket + * @param thePort + * int + */ + public void process(final TcpPacket thePacket, final int thePort) { + handleInput(thePacket, thePort); + } + + /** + * @invisible + * @param thePacket + * TcpPacket + * @param thePort + * int + */ + public abstract void handleInput(final TcpPacket thePacket, + final int thePort); + + /** + * remove a TcpClient from the server's client list. + * @param theTcpClient + * TCPClientAbstract + */ + public void remove(AbstractTcpClient theTcpClient) { + if (_myTcpPacketListener != null && !_myTcpPacketListener.equals(this)) { + _myTcpPacketListener.remove(theTcpClient); + } + theTcpClient.dispose(); + _myTcpClients.removeElement(theTcpClient); + Logger.printProcess("TcpServer", "removing TcpClient."); + } + +} diff --git a/libraries/oscP5/src/netP5/AbstractUdpClient.java b/libraries/oscP5/src/netP5/AbstractUdpClient.java new file mode 100644 index 0000000..45ebd8d --- /dev/null +++ b/libraries/oscP5/src/netP5/AbstractUdpClient.java @@ -0,0 +1,199 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + + +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.SocketException; +import java.net.UnknownHostException; + + + + +/** + * @invisible + */ +public abstract class AbstractUdpClient { + + protected NetAddress _myNetAddress; + + protected DatagramSocket _mySocket; + + protected boolean isRunning = false; + + + /** + * @invisible + */ + public AbstractUdpClient() { + isRunning = openSocket(); + } + + + /** + * @invisible + * @param theAddr String + * @param thePort int + */ + public AbstractUdpClient(String theAddr, int thePort) { + + _myNetAddress = new NetAddress(theAddr, thePort); + + if(!_myNetAddress.isvalid()) { + Logger.printError("UdpClient", "unknown host " + theAddr); + } + isRunning = openSocket(); + } + + /** + * get the datagram socket of the UDP client. more info at java.net.DatagramSocket + * @return DatagramSocket + */ + public DatagramSocket socket() { + return _mySocket; + } + + + + private boolean openSocket() { + try { + _mySocket = new DatagramSocket(); + } + catch (SocketException e) { + Logger.printError("UdpClient.openSocket", "cant create socket " + + e.getMessage()); + return false; + } + + Logger.printProcess("UdpClient.openSocket", "udp socket initialized."); + return true; + } + + /** + * send a string using UDP to an already specified RemoteAddress. + * @param theString + */ + public void send(String theString) { + send(theString.getBytes()); + } + + + /** + * send a byte array using UDP to an already specified RemoteAddress. + * @param theBytes byte[] + */ + public void send(byte[] theBytes) { + if (_myNetAddress.isvalid()) { + send(theBytes, _myNetAddress); + } + else { + Logger.printWarning("UdpClient.send", + "no InetAddress and port has been set. Packet has not been sent."); + } + } + + /** + * send a byte array to the dedicated remoteAddress. + * @param theBytes + * @param theNetAddress + */ + public void send(final byte[] theBytes, + final NetAddress theNetAddress + ) { + if (_myNetAddress.isvalid()) { + send(theBytes, theNetAddress.inetaddress(),theNetAddress.port()); + } + } + + /** + * send a byte array to the dedicated remoteAddress. + * @param thePacket OscPacket + * @param theAddress String + * @param thePort int + */ + public void send(final byte[] theBytes, + final String theAddress, + final int thePort) { + try { + InetAddress myInetAddress = InetAddress.getByName(theAddress); + send(theBytes, myInetAddress, thePort); + } + catch (UnknownHostException e) { + Logger.printError("UdpClient.send", "while sending to " + + theAddress + " " + e); + } + } + + + + /** + * @invisible + * @param thePacket DatagramPacket + */ + public void send(DatagramPacket thePacket) { + if (isRunning) { + try { + _mySocket.send(thePacket); + + } + catch (IOException e) { + Logger.printError("UdpClient.send", + "ioexception while sending packet. "+e); + } + } + } + + + + /** + * send a byte array to the dedicated remoteAddress. + * @param theBytes byte[] + * @param theAddress InetAddress + * @param thePort int + */ + public void send(final byte[] theBytes, + final InetAddress theAddress, + final int thePort) { + if (isRunning) { + try { + DatagramPacket myPacket = new DatagramPacket(theBytes,theBytes.length, theAddress, thePort); + send(myPacket); + } + catch (NullPointerException npe) { + Logger.printError("UdpClient.send", + "a nullpointer exception occured." + npe); + } + } + else { + Logger.printWarning("UdpClient.send", + "DatagramSocket is not running. Packet has not been sent."); + } + } + +} diff --git a/libraries/oscP5/src/netP5/AbstractUdpServer.java b/libraries/oscP5/src/netP5/AbstractUdpServer.java new file mode 100644 index 0000000..9a35d63 --- /dev/null +++ b/libraries/oscP5/src/netP5/AbstractUdpServer.java @@ -0,0 +1,271 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +import java.io.IOException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.UnknownHostException; + + +public abstract class AbstractUdpServer implements Runnable { + + private DatagramSocket _myDatagramSocket = null; + + protected UdpPacketListener _myListener; + + private Thread _myThread = null; + + private int _myPort; + + private String _myAddress; + + private InetAddress _myInetAddress; + + protected int _myDatagramSize = 1536; // common MTU + + private boolean isRunning = true; + + private boolean isSocket = false; + + /** + * create a new UdpServer + * + * @invisible + * @param theListener + * UdpPacketListener + * @param thePort + * int + * @param theBufferSize + * int + */ + public AbstractUdpServer(UdpPacketListener theListener, int thePort, + int theBufferSize) { + _myDatagramSize = theBufferSize; + _myPort = thePort; + _myListener = theListener; + if (_myListener != null) { + start(); + } + } + + /** + * @invisible + * @param theListener + * UdpPacketListener + * @param theAddress + * String + * @param thePort + * int + * @param theBufferSize + * int + */ + protected AbstractUdpServer(UdpPacketListener theListener, + String theAddress, int thePort, int theBufferSize) { + _myDatagramSize = theBufferSize; + _myAddress = theAddress; + _myPort = thePort; + _myListener = theListener; + if (_myListener != null) { + start(); + } + } + + /** + * get the datagram socket of the UDP server. + * + * @return DatagramSocket + */ + public DatagramSocket socket() { + return _myDatagramSocket; + } + + /** + * @invisible + * + */ + public void start() { + _myThread = null; + _myDatagramSocket = null; + _myThread = new Thread(this); + try { + Thread.sleep(1000); + } catch (InterruptedException iex) { + Logger.printError("UdpServer.start()", + "oscServer sleep interruption " + iex); + } + try { + _myDatagramSocket = new DatagramSocket(_myPort); + _myInetAddress = InetAddress.getByName(_myAddress); + Logger.printProcess("UdpServer.start()", + "new Unicast DatagramSocket created @ port " + _myPort); + } catch (IOException ioex) { + Logger.printError("UdpServer.start()", + " IOException, couldnt create new DatagramSocket @ port " + + _myPort + " " + ioex); + } + + if (_myDatagramSocket != null) { + _myThread.start(); + isRunning = _myThread.isAlive(); + isSocket = true; + } else { + isRunning = false; + } + } + + /** + * @invisible + */ + public void run() { + if (_myDatagramSocket != null) { + if (isRunning) { + Logger.printProcess("UdpServer.run()", + "UdpServer is running @ " + _myPort); + } + } else { + Logger.printError("UdpServer.run()", + "Socket is null. closing UdpServer."); + return; + } + + while (isRunning) { + try { + byte[] myBuffer = new byte[_myDatagramSize]; + DatagramPacket myPacket = new DatagramPacket(myBuffer, + _myDatagramSize); + _myDatagramSocket.receive(myPacket); + _myListener.process(myPacket, _myPort); + } catch (IOException ioex) { + Logger.printProcess("UdpServer.run()", " socket closed."); + break; + } catch (ArrayIndexOutOfBoundsException ex) { + Logger.printError("UdpServer.run()", + "ArrayIndexOutOfBoundsException: " + ex); + } + } + dispose(); + } + + /** + * stop the UDP server, clean up and delete its reference. + */ + public void dispose() { + isRunning = false; + _myThread = null; + if (_myDatagramSocket != null) { + if (_myDatagramSocket.isConnected()) { + Logger.printDebug("UdpServer.dispose()", "disconnect()"); + _myDatagramSocket.disconnect(); + } + Logger.printDebug("UdpServer.dispose()", "close()"); + _myDatagramSocket.close(); + _myDatagramSocket = null; + Logger.printDebug("UdpServer.dispose()", + "Closing unicast datagram socket."); + } + } + + /** + * send a byte array to a previously defined remoteAddress. + * + * @param theBytes + * byte[] + */ + public void send(byte[] theBytes) { + if (isSocket) { + send(theBytes, _myInetAddress, _myPort); + } else { + Logger + .printWarning("UdpClient.send", + "no InetAddress and port has been set. Packet has not been sent."); + } + } + + /** + * send a byte array to a dedicated remoteAddress. + * + * @param thePacket + * OscPacket + * @param theAddress + * String + * @param thePort + * int + */ + public void send(byte[] theBytes, String theAddress, int thePort) { + try { + InetAddress myInetAddress = InetAddress.getByName(theAddress); + send(theBytes, myInetAddress, thePort); + } catch (UnknownHostException e) { + Logger.printError("UdpClient.send", "while sending to " + + theAddress + " " + e); + } + } + + /** + * @invisible + * @param thePacket + * DatagramPacket + */ + public void send(DatagramPacket thePacket) { + if (isSocket) { + try { + _myDatagramSocket.send(thePacket); + } catch (IOException e) { + Logger.printError("UdpClient.send", + "ioexception while sending packet."); + } + } + } + + /** + * send a byte array to a dedicated remoteAddress. + * + * @param theBytes + * byte[] + * @param theAddress + * InetAddress + * @param thePort + * int + */ + public void send(byte[] theBytes, InetAddress theAddress, int thePort) { + if (isSocket) { + try { + DatagramPacket myPacket = new DatagramPacket(theBytes, + theBytes.length, theAddress, thePort); + send(myPacket); + } catch (NullPointerException npe) { + Logger.printError("UdpServer.send", + "a nullpointer exception occured." + npe); + } + } else { + Logger.printWarning("UdpServer.send", + "DatagramSocket is not running. Packet has not been sent."); + } + } + +} diff --git a/libraries/oscP5/src/netP5/Bytes.java b/libraries/oscP5/src/netP5/Bytes.java new file mode 100644 index 0000000..7284b3b --- /dev/null +++ b/libraries/oscP5/src/netP5/Bytes.java @@ -0,0 +1,470 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; + + +/** + * @invisible + */ +public class Bytes { + + public Bytes() { + } + + + + /** + * converts an object array into a String that is formated like a list + * + * @param theObject + * Object[] + * @return String + */ + public static String getAsString(Object[] theObject) { + StringBuffer s = new StringBuffer(); + for (int i = 0; i < theObject.length; i++) { + s.append("[" + i + "]" + " " + theObject[i] + "\n"); + } + return s.toString(); + } + + + + public static String getAsString(byte[] theBytes) { + StringBuffer s = new StringBuffer(); + for (int i = 0; i < theBytes.length; i++) { + s.append( (char) theBytes[i]); + } + return s.toString(); + } + + + + public static int toInt(byte abyte0[]) { + return (abyte0[3] & 0xff) + ( (abyte0[2] & 0xff) << 8) + + ( (abyte0[1] & 0xff) << 16) + ( (abyte0[0] & 0xff) << 24); + } + + + + public static long toLong(byte abyte0[]) { + return ( (long) abyte0[7] & 255L) + ( ( (long) abyte0[6] & 255L) << 8) + + ( ( (long) abyte0[5] & 255L) << 16) + + ( ( (long) abyte0[4] & 255L) << 24) + + ( ( (long) abyte0[3] & 255L) << 32) + + ( ( (long) abyte0[2] & 255L) << 40) + + ( ( (long) abyte0[1] & 255L) << 48) + + ( ( (long) abyte0[0] & 255L) << 56); + } + + + + public static float toFloat(byte abyte0[]) { + int i = toInt(abyte0); + return Float.intBitsToFloat(i); + } + + + + public static double toDouble(byte abyte0[]) { + long l = toLong(abyte0); + return Double.longBitsToDouble(l); + } + + + + public static byte[] toBytes(int i) { + return toBytes(i, new byte[4]); + } + + + + public static byte[] toBytes(int i, byte abyte0[]) { + abyte0[3] = (byte) i; + i >>>= 8; + abyte0[2] = (byte) i; + i >>>= 8; + abyte0[1] = (byte) i; + i >>>= 8; + abyte0[0] = (byte) i; + return abyte0; + } + + + + public static byte[] toBytes(long l) { + return toBytes(l, new byte[8]); + } + + + + public static byte[] toBytes(long l, byte abyte0[]) { + abyte0[7] = (byte) (int) l; + l >>>= 8; + abyte0[6] = (byte) (int) l; + l >>>= 8; + abyte0[5] = (byte) (int) l; + l >>>= 8; + abyte0[4] = (byte) (int) l; + l >>>= 8; + abyte0[3] = (byte) (int) l; + l >>>= 8; + abyte0[2] = (byte) (int) l; + l >>>= 8; + abyte0[1] = (byte) (int) l; + l >>>= 8; + abyte0[0] = (byte) (int) l; + return abyte0; + } + + + + public static boolean areEqual(byte abyte0[], byte abyte1[]) { + int i = abyte0.length; + if (i != abyte1.length) { + return false; + } + for (int j = 0; j < i; j++) { + if (abyte0[j] != abyte1[j]) { + return false; + } + } + + return true; + } + + + + public static byte[] append(byte abyte0[], byte abyte1[]) { + byte abyte2[] = new byte[abyte0.length + abyte1.length]; + System.arraycopy(abyte0, 0, abyte2, 0, abyte0.length); + System.arraycopy(abyte1, 0, abyte2, abyte0.length, abyte1.length); + return abyte2; + } + + + + public static byte[] append(byte abyte0[], byte abyte1[], byte abyte2[]) { + byte abyte3[] = new byte[abyte0.length + abyte1.length + abyte2.length]; + System.arraycopy(abyte0, 0, abyte3, 0, abyte0.length); + System.arraycopy(abyte1, 0, abyte3, abyte0.length, abyte1.length); + System.arraycopy(abyte2, 0, abyte3, abyte0.length + abyte1.length, + abyte2.length); + return abyte3; + } + + + + public static byte[] copy(byte abyte0[], int i) { + return copy(abyte0, i, abyte0.length - i); + } + + + + public static byte[] copy(byte abyte0[], int i, int j) { + byte abyte1[] = new byte[j]; + System.arraycopy(abyte0, i, abyte1, 0, j); + return abyte1; + } + + + + public static void merge(byte abyte0[], byte abyte1[], int i, int j, int k) { + System.arraycopy(abyte0, i, abyte1, j, k); + } + + + + public static void merge(byte abyte0[], byte abyte1[], int i) { + System.arraycopy(abyte0, 0, abyte1, i, abyte0.length); + } + + + + public static void merge(byte abyte0[], byte abyte1[]) { + System.arraycopy(abyte0, 0, abyte1, 0, abyte0.length); + } + + + + public static void merge(byte abyte0[], byte abyte1[], int i, int j) { + System.arraycopy(abyte0, 0, abyte1, i, j); + } + + + + public static String toString(byte abyte0[], int i, int j) { + char ac[] = new char[j * 2]; + int k = i; + int l = 0; + for (; k < i + j; k++) { + byte byte0 = abyte0[k]; + ac[l++] = hexDigits[byte0 >>> 4 & 0xf]; + ac[l++] = hexDigits[byte0 & 0xf]; + } + + return new String(ac); + } + + + + public static String toString(byte abyte0[]) { + return toString(abyte0, 0, abyte0.length); + } + + + + public static void printBytes(byte[] byteArray) { + for (int i = 0; i < byteArray.length; i++) { + System.out.print( (char) byteArray[i] + " (" + + hexDigits[byteArray[i] >>> 4 & 0xf] + "" + + hexDigits[byteArray[i] & 0xf] + ") "); + if ( (i + 1) % 4 == 0) { + System.out.print("\n"); + } + } + } + + + + private static final char hexDigits[] = {'0', '1', '2', '3', '4', '5', + '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; + + + /** + * ByteStream + */ + + private static byte[] toByteArray(int in_int) { + byte a[] = new byte[4]; + for (int i = 0; i < 4; i++) { + + int b_int = (in_int >> (i * 8)) & 255; + byte b = (byte) (b_int); + + a[i] = b; + } + return a; + } + + private static byte[] toByteArrayBigEndian(int theInt) { + byte a[] = new byte[4]; + for (int i = 0; i < 4; i++) { + int b_int = (theInt >> (i * 8)) & 255; + byte b = (byte) (b_int); + a[3-i] = b; + } + return a; + } + + + + + private static int asInt(byte[] byte_array_4) { + int ret = 0; + for (int i = 0; i < 4; i++) { + int b = (int) byte_array_4[i]; + if (i < 3 && b < 0) { + b = 256 + b; + } + ret += b << (i * 8); + } + return ret; + } + + + + public static int toIntLittleEndian(InputStream theInputStream) throws java.io.IOException { + byte[] byte_array_4 = new byte[4]; + + byte_array_4[0] = (byte) theInputStream.read(); + byte_array_4[1] = (byte) theInputStream.read(); + byte_array_4[2] = (byte) theInputStream.read(); + byte_array_4[3] = (byte) theInputStream.read(); + + return asInt(byte_array_4); + } + + + public static int toIntBigEndian(InputStream theInputStream) throws java.io.IOException { + byte[] byte_array_4 = new byte[4]; + /* used to reverse the int32 Big Endian of the tcp header to convert it to an int */ + byte_array_4[3] = (byte) theInputStream.read(); + byte_array_4[2] = (byte) theInputStream.read(); + byte_array_4[1] = (byte) theInputStream.read(); + byte_array_4[0] = (byte) theInputStream.read(); + return asInt(byte_array_4); + } + + + public static String toString(InputStream ins) throws java.io.IOException { + int len = toIntLittleEndian(ins); + return toString(ins, len); + } + + + + private static String toString(InputStream ins, int len) throws java.io.IOException { + String ret = new String(); + for (int i = 0; i < len; i++) { + ret += (char) ins.read(); + } + return ret; + } + + + + public static void toStream(OutputStream os, int i) throws Exception { + byte[] byte_array_4 = toByteArrayBigEndian(i); + os.write(byte_array_4); + } + + + + public static void toStream(OutputStream os, String s) throws Exception { + int len_s = s.length(); + toStream(os, len_s); + for (int i = 0; i < len_s; i++) { + os.write( (byte) s.charAt(i)); + } + os.flush(); + } + + + + public static void toStream(OutputStream os, byte[] theBytes) throws Exception { + int myLength = theBytes.length; + toStream(os, myLength); + os.write(theBytes); + os.flush(); + } + + + + public static byte[] toByteArray(InputStream ins) throws java.io.IOException { + int len = toIntLittleEndian(ins); + try { + return toByteArray(ins, len); + } + catch (Exception e) { + return new byte[0]; + } + } + + + + protected static byte[] toByteArray(InputStream ins, int an_int) throws + java.io.IOException, + Exception { + + byte[] ret = new byte[an_int]; + + int offset = 0; + int numRead = 0; + int outstanding = an_int; + + while ( + (offset < an_int) + && + ( (numRead = ins.read(ret, offset, outstanding)) > 0) + ) { + offset += numRead; + outstanding = an_int - offset; + } + if (offset < ret.length) { + throw new Exception("Could not completely read from stream, numRead=" + numRead + ", ret.length=" + ret.length); // ??? + } + return ret; + } + + + + private static void toFile(InputStream ins, FileOutputStream fos, int len, int buf_size) throws + java.io.FileNotFoundException, + java.io.IOException { + + byte[] buffer = new byte[buf_size]; + + int len_read = 0; + int total_len_read = 0; + + while (total_len_read + buf_size <= len) { + len_read = ins.read(buffer); + total_len_read += len_read; + fos.write(buffer, 0, len_read); + } + + if (total_len_read < len) { + toFile(ins, fos, len - total_len_read, buf_size / 2); + } + } + + + + private static void toFile(InputStream ins, File file, int len) throws + java.io.FileNotFoundException, + java.io.IOException { + + FileOutputStream fos = new FileOutputStream(file); + + toFile(ins, fos, len, 1024); + } + + + + public static void toFile(InputStream ins, File file) throws + java.io.FileNotFoundException, + java.io.IOException { + + int len = toIntLittleEndian(ins); + toFile(ins, file, len); + } + + + + public static void toStream(OutputStream os, File file) throws java.io.FileNotFoundException, + Exception { + + toStream(os, (int) file.length()); + + byte b[] = new byte[1024]; + InputStream is = new FileInputStream(file); + int numRead = 0; + + while ( (numRead = is.read(b)) > 0) { + os.write(b, 0, numRead); + } + os.flush(); + } + +} diff --git a/libraries/oscP5/src/netP5/Logger.java b/libraries/oscP5/src/netP5/Logger.java new file mode 100644 index 0000000..63f4f0e --- /dev/null +++ b/libraries/oscP5/src/netP5/Logger.java @@ -0,0 +1,153 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +import java.util.Calendar; + +public class Logger { + + /** + * + */ + public static final int ON = 0; + + /** + * + */ + public static final int OFF = 1; + + /** + * + */ + public static final int ERROR = 0; + + /** + * + */ + public static final int WARNING = 1; + + /** + * + */ + public static final int PROCESS = 2; + + /** + * + */ + public static final int INFO = 3; + + /** + * + */ + public static final int DEBUG = 4; + + /** + * + */ + public static final int ALL = 5; + + + + public static int[] flags = new int[] { ON, ON, ON, ON, OFF }; + + public static void set(int theIndex, int theValue) { + if (theValue > -1 && theValue < 2) { + if (theIndex > -1 && theIndex < flags.length) { + flags[theIndex] = theValue; + return; + } else if (theIndex == ALL) { + for (int i = 0; i < flags.length; i++) { + flags[i] = theValue; + } + return; + } + } + } + + public static void printError(String theLocation, String theMsg) { + if (flags[ERROR] == ON) { + println("### " + getTime() + " ERROR @ " + theLocation + " " + + theMsg); + } + } + + public static void printProcess(String theLocation, String theMsg) { + if (flags[PROCESS] == ON) { + println("### " + getTime() + " PROCESS @ " + theLocation + " " + + theMsg); + } + } + + public static void printWarning(String theLocation, String theMsg) { + if (flags[WARNING] == ON) { + println("### " + getTime() + " WARNING @ " + theLocation + " " + + theMsg); + } + } + + public static void printInfo(String theLocation, String theMsg) { + if (flags[INFO] == ON) { + println("### " + getTime() + " INFO @ " + theLocation + " " + + theMsg); + } + } + + public static void printDebug(String theLocation, String theMsg) { + if (flags[DEBUG] == ON) { + println("### " + getTime() + " DEBUG @ " + theLocation + " " + + theMsg); + } + } + + public static void print(String theMsg) { + System.out.print(theMsg); + } + + public static void println(String theMsg) { + System.out.println(theMsg); + } + + public static void printBytes(byte[] byteArray) { + for (int i = 0; i < byteArray.length; i++) { + print(byteArray[i] + " (" + (char) byteArray[i] + ") "); + if ((i + 1) % 4 == 0) { + print("\n"); + } + } + print("\n"); + } + + public static String getTime() { + Calendar cal = Calendar.getInstance(); + return "[" + (cal.get(Calendar.YEAR)) + "/" + + (cal.get(Calendar.MONTH) + 1) + "/" + + cal.get(Calendar.DAY_OF_MONTH) + " " + + cal.get(Calendar.HOUR_OF_DAY) + ":" + + cal.get(Calendar.MINUTE) + ":" + cal.get(Calendar.SECOND) + + "]"; + } + +} diff --git a/libraries/oscP5/src/netP5/Multicast.java b/libraries/oscP5/src/netP5/Multicast.java new file mode 100644 index 0000000..bc50d2d --- /dev/null +++ b/libraries/oscP5/src/netP5/Multicast.java @@ -0,0 +1,116 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +import java.net.DatagramPacket; +import java.util.Vector; + + +/** + * Multicast is a method of forwarding IP datagrams to a group of interested receivers. + * UDP is used as the transport portocol. + */ +public class Multicast extends AbstractMulticast implements UdpPacketListener { + + + protected Object _myParent; + + protected NetPlug _myNetPlug; + + /** + * create a new instance of Multicast. the buffersize of the datagrams + * is set to 1536 by default. + * + * @param theObject Object + * @param theMulticastAddress String + * @param thePort int + * @param theBufferSize int + */ + public Multicast(final Object theObject, + final String theMulticastAddress, + final int thePort, + final int theBufferSize) { + super(null, theMulticastAddress, thePort, theBufferSize); + _myParent = theObject; + _myListener = this; + _myNetPlug = new NetPlug(_myParent); + init(theMulticastAddress,thePort); + } + + + public Multicast(final Object theObject, + final String theMulticastAddress, + final int thePort) { + super(null, theMulticastAddress, thePort, 1536); + _myParent = theObject; + _myListener = this; + _myNetPlug = new NetPlug(_myParent); + init(theMulticastAddress,thePort); + } + + + public Multicast(final UdpPacketListener theDatagramListener, + final String theMulticastAddress, + final int thePort, + final int theBufferSize) { + super(theDatagramListener, theMulticastAddress, thePort, theBufferSize); + } + + + public Multicast(final UdpPacketListener theDatagramListener, + final String theMulticastAddress, + final int thePort) { + super(theDatagramListener, theMulticastAddress, thePort); + } + + /** + * @invisible + * @param thePacket DatagramPacket + * @param thePort int + */ + public void process(DatagramPacket thePacket, int thePort) { + _myNetPlug.process(thePacket,thePort); + } + + + public void addListener(NetListener theListener) { + _myNetPlug.addListener(theListener); + } + + + public void removeListener(NetListener theListener) { + _myNetPlug.removeListener(theListener); + } + + public NetListener getListener(int theIndex) { + return _myNetPlug.getListener(theIndex); + } + + public Vector getListeners() { + return _myNetPlug.getListeners(); + } + +} diff --git a/libraries/oscP5/src/netP5/NetAddress.java b/libraries/oscP5/src/netP5/NetAddress.java new file mode 100644 index 0000000..09baa6c --- /dev/null +++ b/libraries/oscP5/src/netP5/NetAddress.java @@ -0,0 +1,130 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + + +import java.net.InetAddress; +import java.net.UnknownHostException; + +/** + * NetAddress is an Object that contains an inetaddress + * of an remote internet address, consisting of an + * ip address and a port number. + * @author andreas schlegel + * + */ +public class NetAddress { + protected InetAddress inetaddress = null; + + protected String hostAddress; + + public String name = ""; + + protected int port = 0; + + protected boolean isValid = false; + + /** + * + * @param theAddress String + * @param thePort int + */ + public NetAddress(final String theAddress, + final int thePort) { + hostAddress = theAddress; + port = thePort; + if (thePort > 0) { + try { + inetaddress = InetAddress.getByName(theAddress); + isValid = true; + } + catch (UnknownHostException e) { + System.out.println("no such host " + inetaddress); + } + } + } + + public NetAddress(NetAddress theNetAddress) { + this(theNetAddress.address(),theNetAddress.port()); + } + + + /** + * + * @param theInetAddress InetAddress + * @param thePort int + */ + public NetAddress(InetAddress theInetAddress, int thePort) { + inetaddress = theInetAddress; + hostAddress = inetaddress.getHostAddress(); + port = thePort; + } + + + + /** + * + * @return InetAddress + */ + public InetAddress inetaddress() { + return inetaddress; + } + + + + /** + *returns the remote ip address as string + * @return String + */ + public String address() { + return hostAddress; + } + + + + /** + *returns the remote port number + * @return int + */ + public int port() { + return port; + } + + + + /** + *check if the netAddress is valid. this is true if + * the remote ip address was found. + * @return boolean + */ + public boolean isvalid() { + return isValid; + } + + public String toString() { + return hostAddress+":"+port; + } +} diff --git a/libraries/oscP5/src/netP5/NetAddressList.java b/libraries/oscP5/src/netP5/NetAddressList.java new file mode 100644 index 0000000..44ae782 --- /dev/null +++ b/libraries/oscP5/src/netP5/NetAddressList.java @@ -0,0 +1,169 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + + +import java.util.ArrayList; + +/** + * NetAddressList is an arraylist of netaddresses. + * @author andreas schlegel + */ +public class NetAddressList { + protected ArrayList _myList = new ArrayList(); + + /** + * + * @param theNetAddress NetAddress + */ + public void add(NetAddress theNetAddress) { + if (theNetAddress.isValid == true) { + _myList.add(theNetAddress); + } + } + + + + /** + * + * @param theAddress String + * @param thePort int + */ + public void add(String theAddress, int thePort) { + NetAddress myOscHost = new NetAddress(theAddress, thePort); + if (myOscHost.isValid == true) { + _myList.add(myOscHost); + } + } + + + + /** + * + * @param theAddress String + * @param thePort int + */ + public void remove(String theAddress, int thePort) { + for (int i = 0; i < _myList.size(); i++) { + NetAddress myHost = ( (NetAddress) _myList.get(i)); + if (myHost.hostAddress.equals(theAddress) && myHost.port == thePort) { + _myList.remove(myHost); + } + } + } + + + + /** + * + * @param theNetAddress NetAddress + */ + public void remove(NetAddress theNetAddress) { + _myList.remove(theNetAddress); + } + + + public NetAddress get(String theIPaddress, int thePort) { + for (int i = 0; i < _myList.size(); i++) { + NetAddress myHost = ( (NetAddress) _myList.get(i)); + if (myHost.hostAddress.equals(theIPaddress) && myHost.port == thePort) { + return myHost; + } + } + return null; + + } + + + /** + * + * @param theNetAddress NetAddress + * @return boolean + */ + public boolean contains(NetAddress theNetAddress) { + if (_myList.contains(theNetAddress)) { + return true; + } + return false; + } + + /** + * + * @param theIPaddress String + * @param thePort int + * @return boolean + */ + public boolean contains(String theIPaddress, int thePort) { + for (int i = 0; i < _myList.size(); i++) { + NetAddress myHost = ( (NetAddress) _myList.get(i)); + if (myHost.hostAddress.equals(theIPaddress) && myHost.port == thePort) { + return true; + } + } + return false; + } + + + public int size() { + return _myList.size(); + } + + + + + /** + * + * @param theList NetAddress[] + */ + public void set(NetAddress[] theList) { + _myList = new ArrayList(); + for (int i = 0; i < theList.length; i++) { + _myList.add(theList[i]); + } + } + + + + /** + * + * @return ArrayList + */ + public ArrayList list() { + return _myList; + } + + + + /** + * + * @param theIndex int + * @return NetAddress + */ + public NetAddress get(int theIndex) { + return (NetAddress) _myList.get(theIndex); + } + +} diff --git a/libraries/oscP5/src/netP5/NetInfo.java b/libraries/oscP5/src/netP5/NetInfo.java new file mode 100644 index 0000000..069c2d9 --- /dev/null +++ b/libraries/oscP5/src/netP5/NetInfo.java @@ -0,0 +1,154 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.StringTokenizer; + + +/** + * some description + * @author andreas schlegel + */ +public class NetInfo { + + public NetInfo() { + } + + + + public static void print() { + try { + java.net.InetAddress i = java.net.InetAddress.getLocalHost(); + System.out.println("### hostname/ip " + i); // name and IP address + System.out.println("### hostname " + i.getHostName()); // name + System.out.println("### ip " + i.getHostAddress()); // IP address + // only + } + catch (Exception e) { + e.printStackTrace(); + } + } + + + + public static String getHostAddress() { + try { + java.net.InetAddress i = java.net.InetAddress.getLocalHost(); + return i.getHostAddress(); + } + catch (Exception e) { + } + return "ERROR"; + } + + + + public static String lan() { + Logger.printProcess("NetInfo.checkNetworkStatus : ", getHostAddress()); + return getHostAddress(); + } + + + + public static String wan() { + // create URL object. + String myIp = null; + URL u = null; + String URLstring = "http://checkip.dyndns.org"; + boolean isConnectedToInternet = false; + Logger.printProcess("NetInfo.checkNetworkStatus", + "Checking internet connection ..."); + try { + u = new URL(URLstring); + } + catch (MalformedURLException e) { + Logger.printError("NetInfo.checkNetworkStatus", "Bad URL " + + URLstring + " " + e); + } + + InputStream in = null; + try { + in = u.openStream(); + isConnectedToInternet = true; + } + catch (IOException e) { + Logger.printError("NetInfo.checkNetworkStatus", + "! Unable to open " + URLstring + "\n" + "Either the " + + URLstring + + " is unavailable or this machine is not" + + "connected to the internet !"); + } + + if (isConnectedToInternet) { + try { + BufferedReader br = new BufferedReader( + new InputStreamReader(in)); + String line; + String theToken = ""; + while ( (line = br.readLine()) != null) { + theToken += line; + } + br.close(); + + StringTokenizer st = new StringTokenizer(theToken, " <>", false); + + while (st.hasMoreTokens()) { + String myToken = st.nextToken(); + if (myToken.compareTo("Address:") == 0) { + myToken = st.nextToken(); + myIp = myToken; + Logger.printProcess("NetInfo.checkNetworkStatus", + "WAN address : " + myIp); + } + } + } + catch (IOException e) { + Logger.printError("NetInfo.checkNetworkStatus", + "I/O error reading " + URLstring + + " Exception = " + e); + } + } + return myIp; + } + + + + /** + * + * @param args String[] + * @invisible + */ + public static void main(String[] args) { + NetInfo.wan(); + } +} diff --git a/libraries/oscP5/src/netP5/NetListener.java b/libraries/oscP5/src/netP5/NetListener.java new file mode 100644 index 0000000..2f2fd2a --- /dev/null +++ b/libraries/oscP5/src/netP5/NetListener.java @@ -0,0 +1,34 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +public interface NetListener { + + public void netEvent(NetMessage theNetMessage); + + public void netStatus(NetStatus theStatus); + +} diff --git a/libraries/oscP5/src/netP5/NetMessage.java b/libraries/oscP5/src/netP5/NetMessage.java new file mode 100644 index 0000000..71e2822 --- /dev/null +++ b/libraries/oscP5/src/netP5/NetMessage.java @@ -0,0 +1,148 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + + +import java.net.DatagramPacket; + +import java.net.InetAddress; + + +/** + * @author andreas schlegel + */ +public class NetMessage { + + private InetAddress _myInetAddress; + + private int _myPort; + + private String _myString = ""; + + private byte[] _myData = new byte[0]; + + private TcpClient _myTcpClient; + + private boolean isDatagramPacket = false; + + private int _myProtocol; + + private DatagramPacket _myDatagramPacket; + + private TcpPacket _myTcpPacket; + + protected NetMessage(DatagramPacket theDatagramPacket) { + _myDatagramPacket = theDatagramPacket; + _myInetAddress = theDatagramPacket.getAddress(); + _myPort = theDatagramPacket.getPort(); + _myData = theDatagramPacket.getData(); + _myProtocol = NetP5.UDP; + isDatagramPacket = true; + } + + + protected NetMessage(TcpPacket theTcpPacket) { + _myTcpPacket = theTcpPacket; + _myInetAddress = theTcpPacket.getTcpConnection().socket().getInetAddress(); + _myPort = theTcpPacket.getTcpConnection().socket().getPort(); + _myString = theTcpPacket.getTcpConnection().getString(); + _myData = theTcpPacket.getData(); + _myProtocol = NetP5.TCP; + _myTcpClient = theTcpPacket.getTcpConnection(); + } + + + public TcpPacket getTcpPacket() { + return _myTcpPacket; + } + + public DatagramPacket getDatagramPacket() { + return _myDatagramPacket; + } + + protected void setProtocol(int theType) { + _myProtocol = theType; + } + + + /** + * get the data of the message as bytes. + * @return + */ + public byte[] getData() { + return _myData; + } + + + /** + * get the data the message as string. + * @return + */ + public String getString() { + if(isDatagramPacket) { + return new String(_myData); + } else { + return _myString; + } + } + + /** + * get the protocol type the message was sent over. + * NetP5.TCP or NetP5.UDP are possible. + * @return + */ + public int protocol() { + return _myProtocol; + } + + + /** + * get the port the net message was received at. + * @return + */ + public int port() { + return _myPort; + } + + + + public TcpClient tcpConnection() { + return _myTcpClient; + } + + + + public String address() { + return _myInetAddress.getHostAddress(); + } + + + + public InetAddress inetAddress() { + return _myInetAddress; + } + +} diff --git a/libraries/oscP5/src/netP5/NetP5.java b/libraries/oscP5/src/netP5/NetP5.java new file mode 100644 index 0000000..7a5d69c --- /dev/null +++ b/libraries/oscP5/src/netP5/NetP5.java @@ -0,0 +1,55 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +public interface NetP5 { + + String VERSION = "0.9.9"; + + boolean DEBUG = true; + + /** + * @related setNetworkProtocol ( ) + */ + public final static int UDP = 0; + + /** + * @related setNetworkProtocol ( ) + */ + public final static int MULTICAST = 1; + + + /** + * @related setNetworkProtocol ( ) + */ + public final static int TCP = 2; + /** + * TODO + * authentification in AbstractTcpServer and AbstractUdpServer. + * TcpServer.authentificationRequired(true/false); + * UdpServer.authentificationRequired(true/false); + */ +} diff --git a/libraries/oscP5/src/netP5/NetPlug.java b/libraries/oscP5/src/netP5/NetPlug.java new file mode 100644 index 0000000..f651fc2 --- /dev/null +++ b/libraries/oscP5/src/netP5/NetPlug.java @@ -0,0 +1,222 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; +import java.net.DatagramPacket; +import java.util.Vector; + + + +class NetPlug { + + protected boolean isEventMethod = false; + + protected Method _myEventMethod; + + protected String _myEventMethodName = "netEvent"; + + protected boolean isStatusMethod = false; + + protected Method _myStatusMethod; + + protected String _myStatusMethodName = "netStatus"; + + protected Class _myParentClass; + + protected Object _myParent; + + protected Vector _myNetListeners; + + protected boolean isNetListener; + + protected NetPlug(Object theObject) { + _myParent = theObject; + _myNetListeners = new Vector(); + checkMethod(); + } + + protected void invoke(final Object theObject, final Method theMethod, + final Object[] theArgs) { + try { + theMethod.invoke(theObject, theArgs); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + System.out + .println("NetP5 ClassCastException. parsing failed for NetMessage " + + e); + } + } + + protected void checkMethod() { + try { + checkEventMethod(); + checkStatusMethod(); + } catch (Exception e) { + } + } + + private boolean checkEventMethod() { + _myParentClass = _myParent.getClass(); + if (_myEventMethodName != null) { + try { + _myEventMethod = _myParentClass.getDeclaredMethod( + _myEventMethodName, new Class[] { NetMessage.class }); + isEventMethod = true; + _myEventMethod.setAccessible(true); + return true; + } catch (SecurityException e1) { + e1.printStackTrace(); + } catch (NoSuchMethodException e1) { + System.out + .println("### NOTE. no netEvent(NetMessage theMessage) method available."); + } + } + if (_myEventMethod != null) { + return true; + } + return false; + } + + private boolean checkStatusMethod() { + _myParentClass = _myParent.getClass(); + if (_myStatusMethodName != null) { + try { + _myStatusMethod = _myParentClass.getDeclaredMethod( + _myStatusMethodName, new Class[] { NetStatus.class }); + isStatusMethod = true; + _myStatusMethod.setAccessible(true); + return true; + } catch (SecurityException e1) { + e1.printStackTrace(); + } catch (NoSuchMethodException e1) { + // System.out.println("### NOTE. no netStatus(NetStatus + // theMessage) method available."); + } + } + if (_myStatusMethod != null) { + return true; + } + return false; + } + + /** + * + * @param theDatagramPacket + * DatagramPacket + * @param thePort + * int + * @invisible + */ + public void process(final DatagramPacket theDatagramPacket, + final int thePort) { + if (isNetListener || isEventMethod) { + NetMessage n = new NetMessage(theDatagramPacket); + for (int i = 0; i < _myNetListeners.size(); i++) { + getListener(i).netEvent(n); + } + if (isEventMethod) { + try { + invoke(_myParent, _myEventMethod, new Object[] { n }); + } catch (ClassCastException e) { + System.out + .println("ChatP5.callMessage ClassCastException. failed to forward ChatMessage."); + } + } + } + } + + /** + * @invisible + * @param theIndex + */ + public void status(int theIndex) { + if (isNetListener || isEventMethod) { + NetStatus n = new NetStatus(theIndex); + for (int i = 0; i < _myNetListeners.size(); i++) { + getListener(i).netStatus(n); + } + if (isStatusMethod) { + try { + invoke(_myParent, _myStatusMethod, new Object[] { n }); + } catch (ClassCastException e) { + System.out + .println("ChatP5.callMessage ClassCastException. failed to forward ChatMessage."); + } + } + } + } + + /** + * + * @param theTcpPacket + * TcpPacket + * @param thePort + * int + * @invisible + */ + public void process(final TcpPacket theTcpPacket, final int thePort) { + + if (isNetListener || isEventMethod) { + NetMessage n = new NetMessage(theTcpPacket); + for (int i = 0; i < _myNetListeners.size(); i++) { + getListener(i).netEvent(n); + } + + if (isEventMethod) { + try { + invoke(_myParent, _myEventMethod, new Object[] { n }); + } catch (ClassCastException e) { + System.out + .println("NetP5.callMessage ClassCastException. failed to forward ChatMessage."); + } + } + } + } + + protected void addListener(NetListener theListener) { + _myNetListeners.add(theListener); + isNetListener = true; + } + + protected void removeListener(NetListener theListener) { + _myNetListeners.remove(theListener); + isNetListener = (_myNetListeners.size() > 0) ? true : false; + } + + protected NetListener getListener(int theIndex) { + return ((NetListener) _myNetListeners.get(theIndex)); + } + + protected Vector getListeners() { + return _myNetListeners; + } + +} diff --git a/libraries/oscP5/src/netP5/NetStatus.java b/libraries/oscP5/src/netP5/NetStatus.java new file mode 100644 index 0000000..a16e57d --- /dev/null +++ b/libraries/oscP5/src/netP5/NetStatus.java @@ -0,0 +1,65 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +/** + * @author andreas schlegel + */ +public class NetStatus { + + + public static int ERROR = -1; + + public static int DEFAULT = 0; + + public static int CONNECTION_CLOSED = 1; + + public static int CONNECTION_REFUSED = 2; + + public static int CONNECTION_TERMINATED = 4; + + public static int CONNECTION_FAILED = 8; + + public static int SERVER_CLOSED = 16; + + public static int CLIENT_CLOSED = 32; + + public static int SEND_FAILED = 64; + + private int _myIndex = DEFAULT; + + + public NetStatus(int theIndex) { + _myIndex = theIndex; + } + + + + public int id() { + return _myIndex; + } + +} diff --git a/libraries/oscP5/src/netP5/StringUtils.java b/libraries/oscP5/src/netP5/StringUtils.java new file mode 100644 index 0000000..393bc90 --- /dev/null +++ b/libraries/oscP5/src/netP5/StringUtils.java @@ -0,0 +1,705 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +/** + * StringUtils Contains some basic utility methods for handling Strings. + * + * Copyright (C) 2003 Johan Känngård + * Contains code Copyright (C) 2001,2002 Stephen Ostermiller + * http://ostermiller.org/utils/StringHelper.java.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * The GPL is located at: http://www.gnu.org/licenses/gpl.txt + * + * @author Johan Känngård, http://dev.kanngard.net/ + * @version 0.4 + */ + +package netP5; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Enumeration; +import java.util.StringTokenizer; +import java.util.Vector; + +/** + * @invisible + */ +public class StringUtils extends Object { + + /** + * Protected because this class does only contain static methods. + */ + protected StringUtils() { + } + + /** + * Returns the substring to the right of the specified substring in the + * specified String, starting from the left. + * + * @param source + * the source String to search. + * @param searchFor + * the substring to search for in source. + * @return the substring that is to the right of searchFor in source. + */ + public static String right(String source, String searchFor) { + int index = source.indexOf(searchFor) + searchFor.length(); + + if (index < 0) { + return ""; + } + return source.substring(index); + } + + /** + * Returns the substring to the right of the specified substring in the + * specified String, starting from the right. + * + * @param source + * the source String to search. + * @param searchFor + * the substring to search for in source. + * @return the substring that is to the right of searchFor in source, + * starting from the right. + */ + public static String rightBack(String source, String searchFor) { + int index = source.lastIndexOf(searchFor) + searchFor.length(); + + if (index < 0) { + return ""; + } + return source.substring(index); + } + + /** + * Returns the substring to the left of the specified substring in the + * specified String, starting from the left. + * + * @param source + * the source String to search. + * @param searchFor + * the substring to search for in source. + * @return the substring that is to the left of searchFor in source. + */ + public static String left(String source, String searchFor) { + int index = source.indexOf(searchFor); + + if (index <= 0) { + return ""; + } + return source.substring(0, index); + } + + /** + * Returns the substring to the left of the specified substring in the + * specified String, starting from the right. + * + * @param source + * the source String to search. + * @param searchFor + * the substring to search for in source. + * @return the substring that is to the left of searchFor in source, + * starting from the right. + */ + public static String leftBack(String source, String searchFor) { + int index = source.lastIndexOf(searchFor); + + if (index <= 0) { + return ""; + } + return source.substring(0, index); + } + + /** + * Returns the substring between two substrings. I.e. + * StringUtils.middle("This i a big challenge", "a", "challenge") returns " + * big ". + * + * @param source + * the String to search. + * @param start + * the String to the left to search for, from the left. + * @param end + * the String to the right to search for, from the right. + */ + public static String middle(String source, String start, String end) { + String one = StringUtils.right(source, start); + return StringUtils.leftBack(one, end); + } + + /** + * Returns a substring of a String, starting from specified index and with + * specified length. I. e. StringUtils.middle("This is a big challenge", 5, + * 6) returns " is a " + * + * @param source + * the String to get a substring from. + * @param startIndex + * the index in the source String to get the substring from. + * @param length + * the length of the substring to return. + */ + public static String middle(String source, int startIndex, int length) { + return source.substring(startIndex, source.length() - length); + } + + /** + * Replaces substrings in a string. + * + * @param source + * the source String to replace substrings in. + * @param searchFor + * the string to search for. + * @param replaceWith + * the string to replace all found searchFor-substrings with. + */ + public static String replace(String source, String searchFor, + String replaceWith) { + if (source.length() < 1) { + return ""; + } + int p = 0; + + while (p < source.length() && (p = source.indexOf(searchFor, p)) >= 0) { + source = source.substring(0, p) + replaceWith + + source.substring(p + searchFor.length(), source.length()); + p += replaceWith.length(); + } + return source; + } + + /** + * Replaces several substrings in a string. + * + * @param source + * the source String to replace substrings in. + * @param searchFor + * the substrings to search for. + * @param replaceWith + * what to replace every searchFor with, + */ + public static String replace(String source, String[] searchFor, + String replaceWith) { + for (int i = 0; i < searchFor.length; i++) { + StringUtils.replace(source, searchFor[i], replaceWith); + } + return source; + } + + /** + * Splits every String in an array at the specified lengths. + * + * Example:
+	 * String source[] = { "123a123b123c123d", "Bla1bla2bla3bla4bla5bla6bla7" };
+	 * int[] lengths = { 3, 1, 3, 1 };
+	 * Vector result = StringUtils.explode(source, lengths);
+	 * Object element = null;
+	 * String[] rowElements = null;
+	 * Enumeration enum = result.elements();
+	 * while (enum.hasMoreElements()) {
+	 * 	element = enum.nextElement();
+	 * 	if (element instanceof String[]) {
+	 * 		rowElements = (String[]) element;
+	 * 		for (int i = 0; i < rowElements.length; i++) {
+	 * 			System.out.println(rowElements[i]);
+	 * 		}
+	 * 	}
+	 * }
+	 * 
The result that will be output: 123 a 123 b + * + * Bla 1 bla 2 + * + * @return a Vector containing String arrays (the rows). + */ + public static Vector explode(String[] source, int[] lengths) { + Vector v = new Vector(); + for (int i = 0; i < source.length; i++) { + v.addElement(StringUtils.explode(source[i], lengths)); + } + return v; + } + + /** + * Splits a string at the specified lengths and returns an array of Strings. + * + * @param source + * the String to split. + * @lengths an array of lengths where to split the String. + * @return an array of Strings with the same number of elements as the + * number of elements in the lengths argument. The length of each + * String element is specified by the correspondent lengths array + * element. + * @throws IndexOutOfBoundsException + * if any of the length´s are invalid. + */ + public static String[] explode(String source, int[] lengths) { + String[] result = new String[lengths.length]; + int position = 0; + for (int i = 0; i < lengths.length; i++) { + if (lengths[i] + position > source.length()) { + throw new IndexOutOfBoundsException(); + } + result[i] = source.substring(position, position + lengths[i]); + position += lengths[i]; + } + return result; + } + + /** + * Splits a string into an array with a space as delimiter. + * + * @param source + * the source String to explode. + * @return an array of strings that are made out of splitting the string at + * the spaces. + */ + public static String[] explode(String source) { + return StringUtils.explode(source, " "); + } + + /** + * Splits a string into an array with the specified delimiter. Original code + * Copyright (C) 2001,2002 Stephen Ostermiller + * http://ostermiller.org/utils/StringHelper.java.html + * + *

+ * This method is meant to be similar to the split function in other + * programming languages but it does not use regular expressions. Rather the + * String is split on a single String literal. It is equivalent to the + * + * @Explode function in Lotus Notes / Domino. + *

+ *

+ * Unlike java.util.StringTokenizer which accepts multiple + * character tokens as delimiters, the delimiter here is a single + * String literal. + *

+ *

+ * Each null token is returned as an empty String. Delimiters are + * never returned as tokens. + *

+ *

+ * If there is no delimiter because it is either empty or null, the + * only element in the result is the original String. + *

+ *

+ * StringHelper.explode("1-2-3", "-");
+ * result: {"1", "2", "3"}
+ * StringHelper.explode("-1--2-", "-");
+ * result: {"", "1", ,"", "2", ""}
+ * StringHelper.explode("123", "");
+ * result: {"123"}
+ * StringHelper.explode("1-2---3----4", "--");
+ * result: {"1-2", "-3", "", "4"}
+ *

+ * @param s + * the String to explode. + * @param delimiter + * the delimiter where to split the string. + * @return an array of strings that are made out of splitting the string at + * the specified delimiter. + * @throws NullPointerException + * if s is null. + */ + public static String[] explode(String s, String delimiter) { + int delimiterLength; + int stringLength = s.length(); + + if (delimiter == null || (delimiterLength = delimiter.length()) == 0) { + return new String[] { s }; + } + // a two pass solution is used because a one pass solution would + // require the possible resizing and copying of memory structures + // In the worst case it would have to be resized n times with each + // resize having a O(n) copy leading to an O(n^2) algorithm. + int count = 0; + int start = 0; + int end; + + while ((end = s.indexOf(delimiter, start)) != -1) { + count++; + start = end + delimiterLength; + } + count++; + + String[] result = new String[count]; + // Scan s again, but this time pick out the tokens + count = 0; + start = 0; + while ((end = s.indexOf(delimiter, start)) != -1) { + result[count] = s.substring(start, end); + count++; + start = end + delimiterLength; + } + end = stringLength; + result[count] = s.substring(start, end); + return result; + } + + public static String[] slice(int theNum, String[] theStringArray) { + if (theNum < theStringArray.length) { + String[] t = new String[theStringArray.length - theNum]; + for (int i = theNum; i < theStringArray.length; i++) { + t[i - theNum] = theStringArray[i]; + } + return t; + } + return theStringArray; + } + + /** + * Combines an array to a string, using the specified delimiter. + * + * @param elements + * the array to combine to a single string. + * @param delimiter + * the delimiter to put between the combined elements. + * @return the array combined to a string. + */ + public static String implode(Object[] elements, String delimiter) { + StringBuffer buffer = new StringBuffer(""); + for (int i = 0; i < elements.length - 1; i++) { + buffer.append((String) elements[i] + delimiter); + } + buffer.append((String) elements[elements.length - 1]); + return buffer.toString(); + } + + /** + * Combines an array to a string, using a comma and a space as delimiter. + * + * @param elements + * the array to combine to a single string. + * @return the array combined to a string. + */ + public static String implode(Object[] elements) { + return implode(elements, ", "); + } + + /** + * Used by randomString(int) for valid characters. + */ + protected static String VALID_RANDOM_CHARACTERS = "abcdefghijkmnopqrstuvwxyz" + + "ABCDEFGHJKLMNPQRSTUVWXYZ-_.,;:<>()1234567890%&/=?+"; + + /** + * Removes all instances of a character in a String. + * + * @param source + * the String to remove substring in. + * @param searchFor + * the character to remove. + * @return the replaced String. + */ + public static String remove(String source, char searchFor) { + String s = String.valueOf(searchFor); + return StringUtils.remove(source, s); + } + + /** + * Removes all instances of a substring in a String. + * + * @param source + * the String to remove substring in. + * @param searchFor + * the substring to remove. + * @return the replaced String. + */ + public static String remove(String source, String searchFor) { + + return StringUtils.replace(source, searchFor, ""); + } + + /** + * Removes all instances of substrings in a String. + * + * @param source + * the String to remove substrings in. + * @param searchFor + * an array of substrings to remove from the source String. + * @return the replaced String. + */ + public static String remove(String source, String searchFor[]) { + return StringUtils.replace(source, searchFor, ""); + } + + /** + * Removes duplicates of a substring in a String. Case sensitive. + * + * @param source + * the String to remove duplicates in. + * @param searchFor + * the substring that can only occur one at a time, several can + * exist in the source though. + */ + public static String removeDuplicates(String source, String searchFor) { + StringBuffer result = new StringBuffer(""); + Enumeration myEnum = new StringTokenizer(source, searchFor, true); + String current = ""; + String previous = ""; + + while (myEnum.hasMoreElements()) { + current = (String) myEnum.nextElement(); + if (!current.equals(previous)) { + result.append(current); + } + previous = current; + } + return result.toString(); + } + + /** + * A utility method to remove duplicate characters from a string. For + * example, it would convert "hello" to "helo", and "abcd123abcaaa" to + * "abcd123". + * + * @param source + * the String to remove all duplicate characters in. + * @return a String with no duplicate characters. + */ + protected String unique(String source) { + String result = ""; + + for (int k = 0; k < source.length(); k++) { + if (result.indexOf(source.charAt(k)) == -1) { + result += source.charAt(k); + } + } + return result; + } + + /** + * Prints the stacktrace to a buffer and returns the buffer as a String. + * + * @param t + * the Throwable you wnat to generate a stacktrace for. + * @return the stacktrace of the supplied Throwable. + */ + public static String getStackTrace(Throwable t) throws IOException { + StringWriter sw = new StringWriter(); + t.printStackTrace(new PrintWriter(sw)); + sw.close(); + return sw.toString(); + } + + /** + * Checks if a String is empty or null. + * + * @param s + * the String to test if it is empty or null. + * @return true if the String is null or empty (""). + */ + public static boolean isEmpty(String s) { + if (s == null) { + return true; + } + return s.equals(""); + } + + /** + * Creates a string of the given width with the given string left justified + * (followed by an appropriate number of spaces). + * + * @param source + * the String to justify + * @param length + * the length of the resulting String + * @return the source String padded with spaces to fill up the length. If + * the source string is longer than the length argument, the source + * String is returned. + */ + public static String leftJustify(String source, int length) { + if (source.length() >= length) { + return source; + } + return StringUtils.spaces(length - source.length()) + source; + } + + /** + * Creates a string of the given width with the given string right justified + * (with an appropriate number of spaces before it). + * + * @param source + * the String to justify + * @param length + * the length of the resulting String + * @return the source String padded with spaces to fill up the length. If + * the source string is longer than the length argument, the source + * String is returned. + */ + public static String rightJustify(String source, int length) { + if (source.length() >= length) { + return source; + } + + return source + StringUtils.spaces(length - source.length()); + } + + /** + * Creates a string of the given width with the given string left justified + * (padded by an appropriate number of spaces in front and after it). + * + * @param source + * the String to justify + * @param length + * the length of the resulting String + * @return the source String padded with spaces to fill up the length. If + * the source string is longer than the length argument, the source + * String is returned. + */ + public static String centerJustify(String source, int length) { + if (source.length() >= length) { + return source; + } + int leftLength = (length - source.length()) / 2; + int rightLength = length - (leftLength + source.length()); + return StringUtils.spaces(leftLength) + source + + StringUtils.spaces(rightLength); + } + + /** + * Returns a String with the specified number of spaces. + * + * @param length + * the number of spaces to return. + * @return a String consisting of the specified number of spaces. + */ + public static String spaces(int length) { + return duplicate(" ", length); + } + + /** + * Returns a String with the source String copied the specified number of + * times. + * + * @param source + * the source String to copy. + * @param length + * the number of copies of source to return. + * @return a String consisting of the specified source String copied the + * specified number of times. + */ + public static String duplicate(String source, int copies) { + StringBuffer buf = new StringBuffer(); + for (int i = 0; i < copies; i++) { + buf.append(source); + } + return buf.toString(); + } + + /** + * Switches the case of the supplied String. Any lower case characters will + * be uppercase and vice versa. + * + * @param source + * the String to switch case of. + * @return the supplied String with switched case. + */ + public static String switchCase(String source) { + char[] sourceArray = source.toCharArray(); + StringBuffer result = new StringBuffer(); + + for (int i = 0; i < sourceArray.length; i++) { + result.append(StringUtils.switchCase(sourceArray[i])); + } + return result.toString(); + } + + /** + * Switches the case of the supplied character. A lower case character will + * be uppercase and vice versa. + * + * @param source + * the character to switch case of. + * @return the supplied character with switched case. + */ + public static char switchCase(char source) { + if (Character.isUpperCase(source)) { + return Character.toLowerCase(source); + } + if (Character.isLowerCase(source)) { + return Character.toUpperCase(source); + } + return source; + } + + public static int getInt(String theString) { + int i = 0; + try { + i = Integer.valueOf(theString).intValue(); + } catch (Exception iex) { + } + return i; + } + + public static float getFloat(String theString) { + float i = 0; + try { + i = Float.valueOf(theString).floatValue(); + } catch (Exception iex) { + } + return i; + } + + public static String arrayToString(String[] theArray) { + String myString = ""; + for (int i = 0; i < theArray.length; i++) { + myString += theArray[i] + ","; + } + myString = myString.substring(0, myString.length() - 1); + return myString; + } + + + + public static String arrayToString(String[] theArray, int theStart, int theEnd) { + String myString = ""; + if (theArray.length > theStart) { + for (int i = theStart; i < theEnd; i++) { + myString += theArray[i]+" "; + } + myString = myString.substring(0,myString.length()-1); + } + return myString; + } + + +} diff --git a/libraries/oscP5/src/netP5/TcpClient.java b/libraries/oscP5/src/netP5/TcpClient.java new file mode 100644 index 0000000..05515ad --- /dev/null +++ b/libraries/oscP5/src/netP5/TcpClient.java @@ -0,0 +1,214 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + + +import java.net.Socket; + + +/** + * @author andreas schlegel + */ +public class TcpClient + extends AbstractTcpClient { + + protected final static int NULL = -1; + + protected final static int LISTENER = 0; + + protected final static int EVENT = 1; + + private int _myMode = NULL; + + private Object _myParent; + + private NetPlug _myNetPlug; + + private String _myName = ""; + + /** + * + * @param theAddress String + * @param thePort int + */ + + public TcpClient(final Object theObject, + final String theAddress, + final int thePort) { + super(theAddress, thePort); + _myParent = theObject; + initEvent(); + } + + + /** + * + * @param theObject Object + * @param theAddress String + * @param thePort int + * @param theMode int + */ + public TcpClient(final Object theObject, + final String theAddress, + final int thePort, + final int theMode + ) { + super(theAddress, thePort, theMode); + _myParent = theObject; + initEvent(); + } + + + /** + * + * @param theListener TcpPacketListener + * @param theServerAddress String + * @param theServerPort int + * @param theMode int + */ + public TcpClient(TcpPacketListener theListener, + String theServerAddress, + int theServerPort, + int theMode) { + super(theListener, theServerAddress, theServerPort, theMode); + _myMode = LISTENER; + } + + + + /** + * + * @param theNetAddress NetAddress + */ + public TcpClient(final Object theObject, + final NetAddress theNetAddress) { + super(theNetAddress.address(), theNetAddress.port()); + _myParent = theObject; + initEvent(); + } + + + /** + * + * @param theNetAddress NetAddress + */ + public TcpClient(final NetAddress theNetAddress) { + super(theNetAddress.address(), theNetAddress.port()); + } + + + + /** + * + * @param theAddress String + * @param thePort int + */ + public TcpClient(final String theAddress, + final int thePort) { + super(theAddress, thePort); + } + + + + /** + * @invisible + */ + public TcpClient(AbstractTcpServer theTcpServer, + Socket theSocket, + TcpPacketListener theTcpPacketListener, + int theServerPort, + int theMode) { + super(theTcpServer, + theSocket, + theTcpPacketListener, + theServerPort, + theMode); + _myMode = LISTENER; + } + + + + private void initEvent() { + _myMode = EVENT; + _myNetPlug = new NetPlug(_myParent); + } + + + /** + * @invisible + * @param theIndex int + */ + public void handleStatus(int theIndex) { + switch (_myMode) { + case (EVENT): + _myNetPlug.status(theIndex); + break; + case (LISTENER): + _myTcpPacketListener.status(theIndex); + break; + case (NULL): + Logger.printDebug("TcpClient.handleStatus()","net status id " + theIndex); + break; + } + } + + + /** + * @invisible + */ + public void handleInput() { + switch (_myMode) { + case (EVENT): + _myNetPlug.process(new TcpPacket(this, _myStringBuffer, _myBytes),_myServerPort); + break; + case (LISTENER): + _myTcpPacketListener.process(new TcpPacket(this, _myStringBuffer, _myBytes),_myServerPort); + break; + case (NULL): + Logger.printDebug("TcpClient.handleInput()","received a message : " + _myStringBuffer.toString()); + break; + } + } + + + /** + * + * @return String + */ + public String name() { + return _myName; + } + + + /** + * + * @param theName String + */ + public void setName(String theName) { + _myName = theName; + } + +} diff --git a/libraries/oscP5/src/netP5/TcpPacket.java b/libraries/oscP5/src/netP5/TcpPacket.java new file mode 100644 index 0000000..c3aacb5 --- /dev/null +++ b/libraries/oscP5/src/netP5/TcpPacket.java @@ -0,0 +1,67 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +/** + * @invisible + */ +public class TcpPacket { + + private final TcpClient _myTcpClient; + + private final StringBuffer _myStringBuffer; + + private final byte[] _myData; + + public TcpPacket(final TcpClient theTcpClient, + final StringBuffer theBuffer, + final byte[] theBytes) { + _myStringBuffer = theBuffer; + _myTcpClient = theTcpClient; + _myData = theBytes; + } + + + public TcpClient getTcpConnection() { + return _myTcpClient; + } + + + public String getString() { + return _myStringBuffer.toString(); + } + + + public StringBuffer getStringBuffer() { + return _myStringBuffer; + } + + + public byte[] getData() { + return _myData; + } + +} diff --git a/libraries/oscP5/src/netP5/TcpPacketListener.java b/libraries/oscP5/src/netP5/TcpPacketListener.java new file mode 100644 index 0000000..5587b19 --- /dev/null +++ b/libraries/oscP5/src/netP5/TcpPacketListener.java @@ -0,0 +1,38 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +/** + * @invisible + */ +public interface TcpPacketListener { + + public void process(TcpPacket theTcpPacket, int thePort); + + public void status(int theStatus); + + public void remove(AbstractTcpClient theClient); +} diff --git a/libraries/oscP5/src/netP5/TcpServer.java b/libraries/oscP5/src/netP5/TcpServer.java new file mode 100644 index 0000000..af832a3 --- /dev/null +++ b/libraries/oscP5/src/netP5/TcpServer.java @@ -0,0 +1,177 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +import java.util.Vector; + + + +/** + * @author andreas schlegel + */ +public class TcpServer + extends AbstractTcpServer { + + protected NetPlug _myNetPlug; + + protected Object _myParent; + + protected final static int NULL = -1; + + protected final static int LISTENER = 0; + + protected final static int EVENT = 1; + + protected int _myMode = NULL; + + /** + * @invisible + * @param thePort int + */ + public TcpServer(final int thePort) { + super(thePort, AbstractTcpServer.MODE_READLINE); + } + + + /** + * + * @param theObject Object + * @param thePort int + */ + public TcpServer(final Object theObject, + final int thePort) { + super(thePort, AbstractTcpServer.MODE_READLINE); + _myParent = theObject; + initEvent(); + } + + + /** + * + * @param theObject Object + * @param thePort int + * @param theMode int + */ + public TcpServer(final Object theObject, + final int thePort, + final int theMode) { + super(thePort, theMode); + _myParent = theObject; + initEvent(); + } + + + /** + * + * @param thePort int + * @param theMode int + */ + public TcpServer(final int thePort, + final int theMode) { + super(thePort, theMode); + } + + + /** + * @invisible + * @param theTcpPacketListener TcpPacketListener + * @param thePort int + * @param theMode int + */ + public TcpServer(final TcpPacketListener theTcpPacketListener, + final int thePort, + final int theMode) { + super(theTcpPacketListener, thePort, theMode); + _myMode = LISTENER; + } + + + + private void initEvent() { + _myMode = EVENT; + _myNetPlug = new NetPlug(_myParent); +// _myEventListener.checkMethod(); + + } + + + /** + * @invisible + * @param thePacket TcpPacket + * @param thePort int + */ + public void handleInput(final TcpPacket thePacket, + final int thePort) { + switch (_myMode) { + case (EVENT): + _myNetPlug.process(thePacket, thePort); + break; + case (LISTENER): + break; + case (NULL): + System.out.println("received a message : " + thePacket.getString()); + break; + } + } + + + /** + * @invisible + * @param theIndex int + */ + public void status(final int theIndex) { + switch (_myMode) { + case (EVENT): + _myNetPlug.status(theIndex); + break; + case (LISTENER): + case (NULL): + System.out.println("### status id : " + theIndex); + break; + } + } + + + + public void addListener(NetListener theListener) { + _myNetPlug.addListener(theListener); + } + + + public void removeListener(NetListener theListener) { + _myNetPlug.removeListener(theListener); + } + + public NetListener getListener(int theIndex) { + return _myNetPlug.getListener(theIndex); + } + + public Vector getListeners() { + return _myNetPlug.getListeners(); + } + + +} diff --git a/libraries/oscP5/src/netP5/UdpClient.java b/libraries/oscP5/src/netP5/UdpClient.java new file mode 100644 index 0000000..cb748ef --- /dev/null +++ b/libraries/oscP5/src/netP5/UdpClient.java @@ -0,0 +1,49 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + + +/** + * @author andreas schlegel + */ +public class UdpClient extends AbstractUdpClient { + + public UdpClient() { + super(); + } + + + public UdpClient(String theAddr, int thePort) { + super(theAddr, thePort); + } + + + public UdpClient(NetAddress theNetAddress) { + super(theNetAddress.address(), theNetAddress.port); + } + + +} diff --git a/libraries/oscP5/src/netP5/UdpPacketListener.java b/libraries/oscP5/src/netP5/UdpPacketListener.java new file mode 100644 index 0000000..9283f23 --- /dev/null +++ b/libraries/oscP5/src/netP5/UdpPacketListener.java @@ -0,0 +1,41 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +import java.net.DatagramPacket; + +/** + * @invisible + * @author andreas schlegel + */ +public interface UdpPacketListener { + /** + * + * @param theDatagramPacket + * DatagramPacket + */ + public void process(DatagramPacket theDatagramPacket, int thePort); +} diff --git a/libraries/oscP5/src/netP5/UdpServer.java b/libraries/oscP5/src/netP5/UdpServer.java new file mode 100644 index 0000000..ce4fb0d --- /dev/null +++ b/libraries/oscP5/src/netP5/UdpServer.java @@ -0,0 +1,151 @@ +/** + * A network library for processing which supports UDP, TCP and Multicast. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package netP5; + +import java.net.DatagramPacket; +import java.util.Vector; + + +/** + * + * @author andreas schlegel + * + */ +public class UdpServer extends AbstractUdpServer implements UdpPacketListener { + + protected Object _myParent; + + protected NetPlug _myNetPlug; + + /** + * new UDP server. + * by default the buffersize of a udp packet is 1536 bytes. you can set + * your own individual buffersize with the third parameter int in the constructor. + * @param theObject Object + * @param thePort int + * @param theBufferSize int + */ + public UdpServer( + final Object theObject, + final int thePort, + final int theBufferSize) { + super(null, thePort, theBufferSize); + _myParent = theObject; + _myListener = this; + _myNetPlug = new NetPlug(_myParent); + start(); + } + + + + public UdpServer( + final Object theObject, + final int thePort) { + super(null, thePort, 1536); + _myParent = theObject; + _myListener = this; + _myNetPlug = new NetPlug(_myParent); + start(); + } + + + /** + * @invisible + * @param theListener + * @param thePort + * @param theBufferSize + */ + public UdpServer( + final UdpPacketListener theListener, + final int thePort, + final int theBufferSize) { + super(theListener, thePort, theBufferSize); + } + + + /** + * @invisible + * @param theListener + * @param theAddress + * @param thePort + * @param theBufferSize + */ + protected UdpServer( + final UdpPacketListener theListener, + final String theAddress, + final int thePort, + final int theBufferSize) { + super(theListener, theAddress, thePort, theBufferSize); + } + + + /** + * @invisible + * @param thePacket DatagramPacket + * @param thePort int + */ + public void process(DatagramPacket thePacket, int thePort) { + _myNetPlug.process(thePacket,thePort); + } + + + /** + * add a listener to the udp server. each incoming packet will be forwarded + * to the listener. + * @param theListener + * @related NetListener + */ + public void addListener(NetListener theListener) { + _myNetPlug.addListener(theListener); + } + + /** + * + * @param theListener + * @related NetListener + */ + public void removeListener(NetListener theListener) { + _myNetPlug.removeListener(theListener); + } + + /** + * + * @param theIndex + * @related NetListener + * @return + */ + public NetListener getListener(int theIndex) { + return _myNetPlug.getListener(theIndex); + } + + /** + * @related NetListener + * @return + */ + public Vector getListeners() { + return _myNetPlug.getListeners(); + } +} diff --git a/libraries/oscP5/src/oscP5/OscArgument.java b/libraries/oscP5/src/oscP5/OscArgument.java new file mode 100644 index 0000000..9b09248 --- /dev/null +++ b/libraries/oscP5/src/oscP5/OscArgument.java @@ -0,0 +1,228 @@ +/** + * An OSC (Open Sound Control) library for processing. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + + +package oscP5; + +/** + * an osc argument contains one value of values from a received osc message. + * you can convert the value into the required format, e.g. from Object to int + * theOscMessage.get(0).intValue(); + * @related OscMessage + * @example oscP5oscArgument + */ +public class OscArgument { + protected Object value; + + /** + * @invisible + */ + public OscArgument() {} + + /** + * get the int value of the osc argument. + * @return int + * @related intValue ( ) + * @related floatValue ( ) + * @related charValue ( ) + * @related stringValue ( ) + * @related doubleValue ( ) + * @related longValue ( ) + * @related booleanValue ( ) + * @related bytesValue ( ) + * @related blobValue ( ) + * @example oscP5parsing + */ + public int intValue() { + return ((Integer) value).intValue(); + } + + /** + * get the char value of the osc argument. + * @return char + * @related intValue ( ) + * @related floatValue ( ) + * @related charValue ( ) + * @related stringValue ( ) + * @related doubleValue ( ) + * @related longValue ( ) + * @related booleanValue ( ) + * @related bytesValue ( ) + * @related blobValue ( ) + * @example oscP5parsing + */ + public char charValue() { + return ((Character) value).charValue(); + } + + /** + * get the float value of the osc argument. + * @return float + * @related intValue ( ) + * @related floatValue ( ) + * @related charValue ( ) + * @related stringValue ( ) + * @related doubleValue ( ) + * @related longValue ( ) + * @related booleanValue ( ) + * @related bytesValue ( ) + * @related blobValue ( ) + * @example oscP5parsing + */ + public float floatValue() { + return ((Float) value).floatValue(); + } + + /** + * get the double value of the osc argument. + * @return double + * @related intValue ( ) + * @related floatValue ( ) + * @related charValue ( ) + * @related stringValue ( ) + * @related doubleValue ( ) + * @related longValue ( ) + * @related booleanValue ( ) + * @related bytesValue ( ) + * @related blobValue ( ) + * @example oscP5parsing + */ + public double doubleValue() { + return ((Double) value).doubleValue(); + } + + /** + * get the long value of the osc argument. + * @return long + * @related intValue ( ) + * @related floatValue ( ) + * @related charValue ( ) + * @related stringValue ( ) + * @related doubleValue ( ) + * @related longValue ( ) + * @related booleanValue ( ) + * @related bytesValue ( ) + * @related blobValue ( ) + * @example oscP5parsing + */ + public long longValue() { + return ((Long) value).longValue(); + } + + /** + * get the boolean value of the osc argument. + * @return boolean + * @related intValue ( ) + * @related floatValue ( ) + * @related charValue ( ) + * @related stringValue ( ) + * @related doubleValue ( ) + * @related longValue ( ) + * @related booleanValue ( ) + * @related bytesValue ( ) + * @related blobValue ( ) + * @example oscP5parsing + */ + public boolean booleanValue() { + return ((Boolean) value).booleanValue(); + } + + /** + * get the String value of the osc argument. + * @return String + * @related intValue ( ) + * @related floatValue ( ) + * @related charValue ( ) + * @related stringValue ( ) + * @related doubleValue ( ) + * @related longValue ( ) + * @related booleanValue ( ) + * @related bytesValue ( ) + * @related blobValue ( ) + * @example oscP5parsing + */ + public String stringValue() { + return ((String) value); + } + + + /** + * + * @return String + */ + public String toString() { + return ((String) value); + } + + /** + * get the byte array of the osc argument. + * @return byte[] + * @related intValue ( ) + * @related floatValue ( ) + * @related charValue ( ) + * @related stringValue ( ) + * @related doubleValue ( ) + * @related longValue ( ) + * @related booleanValue ( ) + * @related bytesValue ( ) + * @related blobValue ( ) + * @example oscP5parsing + */ + public byte[] bytesValue() { + return ((byte[]) value); + } + + /** + * get the byte array (blob) of the osc argument. + * @return byte[] + * @related intValue ( ) + * @related floatValue ( ) + * @related charValue ( ) + * @related stringValue ( ) + * @related doubleValue ( ) + * @related longValue ( ) + * @related booleanValue ( ) + * @related bytesValue ( ) + * @related blobValue ( ) + * @example oscP5parsing + */ + public byte[] blobValue() { + return ((byte[]) value); + } + + + /** + * + * @return int[] + */ + public int[] midiValue() { + int[] myInt = new int[4]; + byte[] myByte = (byte[]) value; + for (int i = 0; i < 4; i++) { + myInt[i] = (int) (myByte[i]); + } + return (myInt); + } +} diff --git a/libraries/oscP5/src/oscP5/OscBundle.java b/libraries/oscP5/src/oscP5/OscBundle.java new file mode 100644 index 0000000..d1d79f6 --- /dev/null +++ b/libraries/oscP5/src/oscP5/OscBundle.java @@ -0,0 +1,189 @@ +/** + * An OSC (Open Sound Control) library for processing. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package oscP5; + + +import java.net.DatagramPacket; +import java.util.ArrayList; +import netP5.Bytes; +import netP5.TcpPacket; + + +/** + * Osc Bundles are collections of Osc Messages. use bundles to send multiple + * osc messages to one destination. the OscBundle timetag is supported for + * sending but not for receiving yet. + * @related OscMessage + * @related OscP5 + * @example oscP5bundle + */ +public class OscBundle extends OscPacket { + + protected static final int BUNDLE_HEADER_SIZE = 16; + + protected static final byte[] BUNDLE_AS_BYTES = {0x23, 0x62, 0x75, 0x6E, + 0x64, 0x6C, 0x65, 0x00}; + + private int _myMessageSize = 0; + + /** + * instantiate a new OscBundle object. + */ + public OscBundle() { + messages = new ArrayList(); + } + + + protected OscBundle(DatagramPacket theDatagramPacket) { + inetAddress = theDatagramPacket.getAddress(); + port = theDatagramPacket.getPort(); + hostAddress = inetAddress.toString(); + _myMessageSize = parseBundle(theDatagramPacket.getData(), inetAddress, port, null); + _myType = BUNDLE; + } + + + protected OscBundle(TcpPacket thePacket) { + _myTcpClient = thePacket.getTcpConnection(); + inetAddress = _myTcpClient.netAddress().inetaddress(); + port = _myTcpClient.netAddress().port(); + hostAddress = inetAddress.toString(); + _myMessageSize = parseBundle(thePacket.getData(), inetAddress, port, _myTcpClient); + _myType = BUNDLE; + } + + + /** + * add an osc message to the osc bundle. + * @param theOscMessage OscMessage + */ + public void add(OscMessage theOscMessage) { + messages.add(new OscMessage(theOscMessage)); + _myMessageSize = messages.size(); + } + + + /** + * clear and reset the osc bundle for reusing. + * @example oscP5bundle + */ + public void clear() { + messages = new ArrayList(); + } + + + /** + * remove an OscMessage from an OscBundle. + * @param theIndex int + */ + public void remove(int theIndex) { + messages.remove(theIndex); + } + + + /** + * + * @param theOscMessage OscMessage + */ + public void remove(OscMessage theOscMessage) { + messages.remove(theOscMessage); + } + + + /** + * request an osc message inside the osc bundle array, + * @param theIndex int + * @return OscMessage + */ + public OscMessage getMessage(int theIndex) { + return messages.get(theIndex); + } + + + /** + * get the size of the osc bundle array which contains the osc messages. + * @return int + * @example oscP5bundle + */ + public int size() { + return _myMessageSize; + } + + + /** + * set the timetag of an osc bundle. timetags are used to synchronize events and + * execute events at a given time in the future or immediately. timetags can + * only be set for osc bundles, not for osc messages. oscP5 supports receiving + * timetags, but does not queue messages for execution at a set time. + * @param theTime long + * @example oscP5bundle + */ + public void setTimetag(long theTime) { + final long secsSince1900 = theTime / 1000 + TIMETAG_OFFSET; + final long secsFractional = ((theTime % 1000) << 32) / 1000; + timetag = (secsSince1900 << 32) | secsFractional; + } + + + /** + * returns the current time in milliseconds. use with setTimetag. + * @return long + */ + public static long now() { + return System.currentTimeMillis(); + } + + + /** + * returns a timetag as byte array. + * @return byte[] + */ + public byte[] timetag() { + return Bytes.toBytes(timetag); + } + + + /** + * @todo get timetag as Date + */ + + /** + * + * @return byte[] + * @invisible + */ + public byte[] getBytes() { + byte[] myBytes = new byte[0]; + myBytes = Bytes.append(myBytes, BUNDLE_AS_BYTES); + myBytes = Bytes.append(myBytes, timetag()); + for (int i = 0; i < size(); i++) { + byte[] tBytes = getMessage(i).getBytes(); + myBytes = Bytes.append(myBytes, Bytes.toBytes(tBytes.length)); + myBytes = Bytes.append(myBytes, tBytes); + } + return myBytes; + } +} diff --git a/libraries/oscP5/src/oscP5/OscEventListener.java b/libraries/oscP5/src/oscP5/OscEventListener.java new file mode 100644 index 0000000..18c9e2c --- /dev/null +++ b/libraries/oscP5/src/oscP5/OscEventListener.java @@ -0,0 +1,37 @@ +/** + * An OSC (Open Sound Control) library for processing. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package oscP5; + +/** + * + * @invisible + */ +public interface OscEventListener { + + public void oscEvent(OscMessage theMessage); + + public void oscStatus(OscStatus theStatus); +} diff --git a/libraries/oscP5/src/oscP5/OscIn.java b/libraries/oscP5/src/oscP5/OscIn.java new file mode 100644 index 0000000..509b8e2 --- /dev/null +++ b/libraries/oscP5/src/oscP5/OscIn.java @@ -0,0 +1,89 @@ +/** + * An OSC (Open Sound Control) library for processing. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package oscP5; + +import java.util.ArrayList; + +/** + * OscIn is deprecated. for compatibility with previous versions of oscP5 OscIn + * is still available. + * + * @invisible + */ +@Deprecated +public class OscIn extends OscMessage { + + public OscIn(OscMessage theOscMessage) { + super(theOscMessage); + } + + public int getInt(int thePos) { + return get(thePos).intValue(); + } + + public char getChar(int thePos) { + return get(thePos).charValue(); + } + + public float getFloat(int thePos) { + return get(thePos).floatValue(); + } + + public String getString(int thePos) { + return get(thePos).stringValue(); + } + + public byte[] getBlob(int thePos) { + return get(thePos).bytesValue(); + } + + public int[] getMidiBytes(int thePos) { + return get(thePos).midiValue(); + } + + public int[] getMidi(int thePos) { + return get(thePos).midiValue(); + } + + public boolean getBoolean(int thePos) { + return get(thePos).booleanValue(); + } + + /** + * this is only for christian's and jens' table communication with vvvv. + * + * @return ArrayList + */ + public ArrayList getDataList() { + ArrayList myList = new ArrayList(); + Object[] myArguments = arguments(); + for (int i = 0; i < myArguments.length; i++) { + myList.add(myArguments[i]); + } + return myList; + } + +} diff --git a/libraries/oscP5/src/oscP5/OscMessage.java b/libraries/oscP5/src/oscP5/OscMessage.java new file mode 100644 index 0000000..153cfba --- /dev/null +++ b/libraries/oscP5/src/oscP5/OscMessage.java @@ -0,0 +1,764 @@ +/** + * An OSC (Open Sound Control) library for processing. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package oscP5; + + +import java.net.DatagramPacket; + +import java.net.InetAddress; +import netP5.Bytes; +import netP5.Logger; +import netP5.TcpClient; +import netP5.TcpPacket; + + +/** + * An OSC message consists of an OSC Address Pattern, an OSC Type Tag String + * and the OSC arguments. + * + * @related OscBundle + * @example oscP5sendReceive + */ +public class OscMessage extends OscPacket { + + protected final OscArgument _myOscArgument = new OscArgument(); + + protected boolean isPlugged = false; + + protected OscMessage(final DatagramPacket theDatagramPacket) { + inetAddress = theDatagramPacket.getAddress(); + port = theDatagramPacket.getPort(); + hostAddress = inetAddress.toString(); + parseMessage(theDatagramPacket.getData()); + _myType = MESSAGE; + } + + + protected OscMessage(final TcpPacket thePacket) { + _myTcpClient = thePacket.getTcpConnection(); + inetAddress = _myTcpClient.netAddress().inetaddress(); + port = _myTcpClient.netAddress().port(); + hostAddress = inetAddress.toString(); + parseMessage(thePacket.getData()); + _myType = MESSAGE; + } + + + /** + * + * @param theOscMessage OscMessage + * @invisible + */ + + public OscMessage(final OscMessage theOscMessage) { + inetAddress = theOscMessage.inetAddress; + port = theOscMessage.port; + hostAddress = theOscMessage.hostAddress; + _myTcpClient = theOscMessage.tcpConnection(); + _myAddrPattern = theOscMessage._myAddrPattern; + _myTypetag = theOscMessage._myTypetag; + _myData = theOscMessage._myData; + _myArguments = theOscMessage._myArguments; + isValid = true; + } + + + /** + * + * @param theAddrPattern + * String + */ + public OscMessage(final String theAddrPattern) { + this(theAddrPattern, new Object[0]); + } + + + /** + * + * @param theAddrInt + * int + */ + public OscMessage(final int theAddrInt) { + this(theAddrInt, new Object[0]); + } + + + /** + * + * @param theAddrPattern String + * @param theArguments + * Object[] + */ + public OscMessage(final String theAddrPattern, + final Object[] theArguments) { + init(); + setAddrPattern(theAddrPattern); + setArguments(theArguments); + } + + + /** + * + * @param theAddrPattern int + * @param theArguments Object[] + */ + public OscMessage(final int theAddrPattern, + final Object[] theArguments) { + init(); + setAddrPattern(theAddrPattern); + setArguments(theArguments); + } + + + protected OscMessage(final byte[] theBytes, + final InetAddress theInetAddress, + final int thePort, + final TcpClient theClient + ) { + _myTcpClient = theClient; + inetAddress = theInetAddress; + port = thePort; + hostAddress = inetAddress.toString(); + parseMessage(theBytes); + } + + protected OscMessage(final byte[] theBytes, + final InetAddress theInetAddress, + final int thePort, + final long theTimetag, + final TcpClient theClient + ) { + this(theBytes,theInetAddress,thePort,theClient); + timetag = theTimetag; + } + + + + protected void init() { + _myTypetag = new byte[0]; + _myData = new byte[0]; + } + + + /** + * clear and reset an OscMessage for reuse. + */ + public void clear() { + init(); + setAddrPattern(""); + setArguments(new Object[0]); + } + + /** + * clears the arguments in a message, + * but keeps the address the address pattern. + * + */ + public void clearArguments() { + _myTypetag = new byte[0]; + _myData = new byte[0]; + _myArguments = new Object[0]; + } + + + /** + * TODO + * set should enable the programmer to set values + * of an existing osc message. + */ + public void set(final int theIndex, final Object theObject) { +// byte[] myPreTypetag = new byte[theIndex]; +// byte[] myPostTypetag = new byte[_myTypetag.length - theIndex]; + System.out.println("Typetag:\t" + _myTypetag.length); + System.out.println("Arguments:\t"); + Bytes.printBytes(_myData); + System.out.println(_myArguments.length); + for(int i=0;i<_myArguments.length;i++) { + System.out.println(_myArguments[i]); + } + } + + + /** + * + * @param theTypeTag + * String + * @return boolean + * @example oscP5parsing + */ + public boolean checkTypetag(final String theTypeTag) { + return theTypeTag.equals(typetag()); + } + + + /** + * check if an address pattern equals a specific address pattern + * you are looking for. this is usually used when parsing an osc message. + * e.g. if(theOscMessage.checkAddrPattern("/test")==true) {...} + * @param theAddrPattern + * String + * @return boolean + * @example oscP5parsing + */ + public boolean checkAddrPattern(final String theAddrPattern) { + return theAddrPattern.equals(addrPattern()); + } + + + /** + * set the address pattern of an osc message. you can set + * a string or an int as address pattern.tnt might be useful for + * supercollider users. oscP5 does support ints and strings as + * address patterns when sending and receiving messages. + * @param theAddrPattern + * String + */ + public void setAddrPattern(final String theAddrPattern) { + _myAddrPattern = theAddrPattern.getBytes(); + } + + + /** + * + * @param theAddrPattern + * int + */ + public void setAddrPattern(final int theAddrPattern) { + _myAddrPattern = Bytes.toBytes(theAddrPattern); + } + + + /** + * set the arguments of the osc message using an object array. + * with version 0.9.4 the existing arguments are overwritten, + * to add the arguments to the argument list, use addArguments(Object[]) + * @param theArguments + * Object[] + */ + public void setArguments(final Object[] theArguments) { + clearArguments(); + addArguments(theArguments); + } + + /** + * add a list of arguments to an exisiting set of arguments. + * to overwrite the existing argument list, use setArguments(Object[]) + * + * @param theArguments + */ + public OscMessage addArguments(final Object[] theArguments) { + return add(theArguments); + } + + + public String addrPattern() { + return Bytes.getAsString(_myAddrPattern); + } + + + /** + * returns the address pattern of the osc message as int. + * @return int + */ + public int addrInt() { + return _myAddrInt; + } + + + /** + * returns the typetag of the osc message. e.g. the message contains + * 3 floats then the typetag would be "fff" + * @return String + */ + public String typetag() { + return Bytes.getAsString(_myTypetag); + } + + /** + * get the timetag of an osc message. timetags are only sent by + * osc bundles. + * @return long + */ + public long timetag() { + return timetag; + } + + /** + * + * @return Object[] + */ + public Object[] arguments() { + return _myArguments; + } + + + /** + * supported arrays see OscPlug.getArgs + * @return Object[] + */ + protected Object[] argsAsArray() { + switch (_myTypetag[0]) { + case (0X66): // float f + final float[] myFloatArray = new float[_myArguments.length]; + for (int i = 0; i < myFloatArray.length; i++) { + myFloatArray[i] = ((Float) _myArguments[i]).floatValue(); + } + return new Object[] {myFloatArray}; + case (0x69): // int i + final int[] myIntArray = new int[_myArguments.length]; + for (int i = 0; i < myIntArray.length; i++) { + myIntArray[i] = ((Integer) _myArguments[i]).intValue(); + } + return new Object[] {myIntArray}; + case (0x53): // Symbol S + case (0x73): // String s + final String[] myStringArray = new String[_myArguments.length]; + for (int i = 0; i < myStringArray.length; i++) { + myStringArray[i] = ((String) _myArguments[i]); + } + return new Object[] {myStringArray}; + default: + break; + } + return new Object[] {}; + } + + /** + * + * @return byte[] + * @invisible + */ + public byte[] getAddrPatternAsBytes() { + return Bytes.append(_myAddrPattern, + new byte[align(_myAddrPattern.length)]); + } + + + /** + * + * @return byte[] + * @invisible + */ + public byte[] getTypetagAsBytes() { + return _myTypetag; + } + + + /** + * + * @return byte[] + * @invisible + */ + public byte[] getBytes() { + byte[] myBytes = new byte[0]; + byte[] myTypeTag = Bytes.copy(_myTypetag, 0); + myBytes = Bytes.append(myBytes, _myAddrPattern, + new byte[align(_myAddrPattern.length)]); + if (myTypeTag.length == 0) { + myTypeTag = new byte[] {KOMMA}; + } else if (myTypeTag[0] != KOMMA) { + myTypeTag = Bytes.append(new byte[] {KOMMA}, myTypeTag); + } + myBytes = Bytes.append(myBytes, myTypeTag, + new byte[align(myTypeTag.length)]); + myBytes = Bytes.append(myBytes, _myData, + new byte[align(_myData.length) % 4]); + return myBytes; + } + + + protected Object[] increase(int theAmount) { + if(_myArguments.length<1 || _myArguments == null) { + return new Object[1]; + } + Object[] myArguments = new Object[_myArguments.length + theAmount]; + System.arraycopy(_myArguments, 0, myArguments, 0, _myArguments.length); + return myArguments; + } + /** + * add values to an osc message. please check the + * add documentation for specific information. + * @example oscP5message + */ + public OscMessage add() { + _myTypetag = Bytes.append(_myTypetag, new byte[] {0x4e}); + return this; + } + + + /** + * @param theValue int + */ + public OscMessage add(final int theValue) { + _myTypetag = Bytes.append(_myTypetag, new byte[] {0x69}); + _myData = Bytes.append(_myData, Bytes.toBytes(theValue)); + _myArguments = increase(1); + _myArguments[_myArguments.length-1] = new Integer(theValue); + return this; + } + + + /** + * + * @param theValue String + */ + public OscMessage add(final String theValue) { + _myTypetag = Bytes.append(_myTypetag, new byte[] {0x73}); + final byte[] myString = theValue.getBytes(); + _myData = Bytes.append(_myData, myString, + new byte[align(myString.length)]); + _myArguments = increase(1); + _myArguments[_myArguments.length-1] = theValue; + return this; + } + + + /** + * + * @param theValue float + */ + public OscMessage add(final float theValue) { + _myTypetag = Bytes.append(_myTypetag, new byte[] {0x66}); + _myData = Bytes.append(_myData, Bytes.toBytes(Float + .floatToIntBits(theValue))); + _myArguments = increase(1); + _myArguments[_myArguments.length-1] = new Float(theValue); + return this; + } + + + /** + * + * @param theValue double + */ + public OscMessage add(final double theValue) { + _myTypetag = Bytes.append(_myTypetag, new byte[] {0x64}); + _myData = Bytes.append(_myData, Bytes.toBytes(Double + .doubleToLongBits(theValue))); + _myArguments = increase(1); + _myArguments[_myArguments.length-1] = new Double(theValue); + return this; + } + + + /** + * + * @param theValue boolean + */ + public OscMessage add(final boolean theValue) { + if (theValue) { + _myTypetag = Bytes.append(_myTypetag, new byte[] {0x54}); + } else { + _myTypetag = Bytes.append(_myTypetag, new byte[] {0x46}); + } + return this; + } + + + /** + * + * @param theValue Boolean + */ + public OscMessage add(final Boolean theValue) { + add((theValue).booleanValue()); + return this; + } + + + /** + * + * @param theValue Integer + */ + public OscMessage add(final Integer theValue) { + add(theValue.intValue()); + return this; + } + + + /** + * + * @param theValue + * Float + */ + public OscMessage add(final Float theValue) { + add(theValue.floatValue()); + return this; + } + + + /** + * + * @param theValue + * Double + */ + public OscMessage add(final Double theValue) { + add(theValue.doubleValue()); + return this; + } + + + /** + * + * @param theValue + * Character + */ + public OscMessage add(final Character theValue) { + add(theValue.charValue()); + return this; + } + + + /** + * + * @param theValue + * char + */ + public OscMessage add(final char theValue) { + _myTypetag = Bytes.append(_myTypetag, new byte[] {0x63}); + _myData = Bytes.append(_myData, Bytes.toBytes(theValue)); + _myArguments = increase(1); + _myArguments[_myArguments.length-1] = new Character(theValue); + return this; + } + + + /** + * + * @param channel int + * @param status int + * @param value1 int + * @param value2 int + */ + + public OscMessage add(final int channel, + final int status, + final int value1, + final int value2) { + _myTypetag = Bytes.append(_myTypetag, new byte[] {0x6d}); // m + final byte[] theBytes = new byte[4]; + theBytes[0] = (byte) channel; + theBytes[1] = (byte) status; + theBytes[2] = (byte) value1; + theBytes[3] = (byte) value2; + _myData = Bytes.append(_myData, theBytes); + _myArguments = increase(1); + _myArguments[_myArguments.length-1] = theBytes; + return this; + } + + + /** + * + * @param theArray + * int[] + */ + public OscMessage add(final int[] theArray) { + for (int i = 0; i < theArray.length; i++) { + add(theArray[i]); + } + return this; + } + + + /** + * + * @param theArray + * char[] + */ + public OscMessage add(final char[] theArray) { + for (int i = 0; i < theArray.length; i++) { + add(theArray[i]); + } + return this; + } + + + /** + * + * @param theArray + * float[] + */ + public OscMessage add(final float[] theArray) { + for (int i = 0; i < theArray.length; i++) { + add(theArray[i]); + } + return this; + } + + + /** + * + * @param theArray + * String[] + */ + public OscMessage add(final String[] theArray) { + for (int i = 0; i < theArray.length; i++) { + add(theArray[i]); + } + return this; + } + + + /** + * + * @param theArray + * byte[] + */ + public OscMessage add(final byte[] theArray) { + _myTypetag = Bytes.append(_myTypetag, new byte[] {0x62}); + _myData = Bytes.append(_myData, makeBlob(theArray)); + _myArguments = increase(1); + _myArguments[_myArguments.length-1] = theArray; + return this; + } + + + /** + * + * @param theArray + * Object[] + */ + public OscMessage add(final Object[] theArray) { + for (int i = 0; i < theArray.length; i++) { + if (!add(theArray[i])) { + System.out.println("type of Argument not defined in osc specs."); + } + } + return this; + } + + + private boolean add(final Object theObject) { + if (theObject instanceof Number) { + if (theObject instanceof Integer) { + add((Integer) theObject); + } else if (theObject instanceof Float) { + add((Float) theObject); + } else if (theObject instanceof Double) { + add((Double) theObject); + } else if (theObject instanceof Long) { + add((Long) theObject); + } + } else if (theObject instanceof String) { + add((String) theObject); + } else if (theObject instanceof Boolean) { + add((Boolean) theObject); + } else if (theObject instanceof Character) { + add((Character) theObject); + } + + else { + if (theObject instanceof int[]) { + add((int[]) theObject); + return true; + } else if (theObject instanceof float[]) { + add((float[]) theObject); + return true; + } else if (theObject instanceof byte[]) { + add((byte[]) theObject); + return true; + } + + else if (theObject instanceof String[]) { + add((String[]) theObject); + return true; + } else if (theObject instanceof char[]) { + add((char[]) theObject); + return true; + } else if (theObject instanceof double[]) { + add((float[]) theObject); + return true; + } + return false; + } + return true; + } + + + /** + * + * @param b byte[] + * @return byte[] + * @invisible + */ + public static byte[] makeBlob(final byte[] b) { + final int tLength = b.length; + byte[] b1 = Bytes.toBytes(tLength); + b1 = Bytes.append(b1, b); + final int t = tLength % 4; + if (t != 0) { + b1 = Bytes.append(b1, new byte[4 - t]); + } + return b1; + } + + + /** + * get a value at a specific position in the osc message. the get method + * returns an OscArgument from which the value can be parsed into the right + * format. e.g. to parse an int from the first argument in the osc message, + * use theOscMessage.get(0).intValue(); + * @param theIndex int + * @return OscArgument + */ + public OscArgument get(final int theIndex) { + if (theIndex < arguments().length) { + _myOscArgument.value = arguments()[theIndex]; + return _myOscArgument; + } + return null; + } + + + /** + * + * @return String + * @invisible + */ + public final String toString() { + return hostAddress + ":" + port + " | " + + addrPattern() + " " + typetag(); + } + + + public boolean isPlugged() { + return isPlugged; + } + + + public void print() { + Logger.println("-OscMessage----------"); + Logger.println("received from\t" + hostAddress + ":" + port); + Logger.println("addrpattern\t" + Bytes.getAsString(_myAddrPattern)); + Logger.println("typetag\t" + Bytes.getAsString(_myTypetag)); + Logger.println(Bytes.getAsString(_myArguments)); + Logger.println("---------------------"); + } + + public void printData() { + Bytes.printBytes(_myData); + } +} diff --git a/libraries/oscP5/src/oscP5/OscNetManager.java b/libraries/oscP5/src/oscP5/OscNetManager.java new file mode 100644 index 0000000..dd4f614 --- /dev/null +++ b/libraries/oscP5/src/oscP5/OscNetManager.java @@ -0,0 +1,386 @@ +/** + * An OSC (Open Sound Control) library for processing. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package oscP5; + +import java.net.DatagramPacket; +import java.util.ArrayList; + +import netP5.AbstractMulticast; +import netP5.AbstractTcpClient; +import netP5.Logger; +import netP5.Multicast; +import netP5.NetAddress; +import netP5.NetAddressList; +import netP5.TcpClient; +import netP5.TcpPacket; +import netP5.TcpPacketListener; +import netP5.TcpServer; +import netP5.UdpClient; +import netP5.UdpPacketListener; +import netP5.UdpServer; + + +/** + * @invisible + */ + +public class OscNetManager + implements UdpPacketListener, TcpPacketListener { + + protected OscProperties _myOscProperties; + + protected UdpClient _myUdpClient = null; + + protected UdpServer _myUdpServer = null; + + protected TcpServer _myTcpServer = null; + + protected TcpClient _myTcpClient = null; + + protected boolean isTcpClient = false; + + protected boolean isTcpServer = false; + + protected AbstractMulticast _myMulticast = null; + + protected ArrayList _myUdpListener = new ArrayList(); + + protected ArrayList _myTcpListener = new ArrayList(); + + public final static int NONE = 0; + + public void start(final OscProperties theOscProperties) { + stop(); + _myOscProperties = theOscProperties; + int networkProtocol = _myOscProperties.networkProtocol(); + switch (networkProtocol) { + case (OscProperties.UDP): + newUdp(); + break; + case (OscProperties.MULTICAST): + newMulticast(); + break; + case (OscProperties.TCP): + newTcp(); + break; + } + _myOscProperties.isLocked = true; + } + + + protected void stop() { + _myUdpClient = null; + if (_myMulticast != null) { + Logger.printDebug("OscP5.stop", "multicast."); + _myMulticast.dispose(); + } + if (_myUdpServer != null) { + Logger.printDebug("OscP5.stop", "stopping udpserver."); + _myUdpServer.dispose(); + } + _myMulticast = null; + _myUdpServer = null; + Logger.printProcess("OscP5", "stopped."); + } + + + private void newUdp() { + if (_myOscProperties.remoteAddress() != null && _myOscProperties.remoteAddress().isvalid()) { + _myUdpClient = new UdpClient(_myOscProperties.remoteAddress().address(), _myOscProperties.remoteAddress().port()); + } + else { + _myUdpClient = new UdpClient(); + } + + if (_myOscProperties.listeningPort() > 0) { + _myUdpServer = new UdpServer(this, _myOscProperties.listeningPort(), _myOscProperties.datagramSize()); + } + } + + + private void newTcp() { + if (_myOscProperties.listeningPort() > 0) { + _myTcpServer = new TcpServer(this, _myOscProperties.listeningPort(), TcpServer.MODE_STREAM); + isTcpServer = true; + } + else if (_myOscProperties.remoteAddress().isvalid()) { + _myTcpClient = new TcpClient( + this, + _myOscProperties.remoteAddress().address(), + _myOscProperties.remoteAddress().port(), + TcpClient.MODE_STREAM); + isTcpClient = true; + } + } + + + private void newMulticast() { + if (_myOscProperties.remoteAddress() != null && _myOscProperties.remoteAddress().isvalid()) { + _myMulticast = new Multicast( + this, + _myOscProperties.remoteAddress().address(), + _myOscProperties.remoteAddress().port(), + _myOscProperties.datagramSize()); + + } + else { + // ESCA-JAVA0266: + System.out.println("ERROR @ Multicast"); + } + + } + + + public void setTimeToLive(final int theTTL) { + if (_myMulticast != null) { + _myMulticast.setTimeToLive(theTTL); + } + else { + Logger.printWarning("OscNetManager.setTimeToLive", "only supported for multicast session."); + } + } + + + public TcpServer tcpServer() { + return _myTcpServer; + } + + + public TcpClient tcpClient() { + return _myTcpClient; + } + + + /** + * @param theListener DatagramPacketListener + */ + public void addUdpListener(final UdpPacketListener theListener) { + _myUdpListener.add(theListener); + } + + + /** + * @param theListener DatagramPacketListener + */ + public void removeUdpListener(final UdpPacketListener theListener) { + _myUdpListener.remove(theListener); + } + + + /** + * @param theListener TcpPacketListener + */ + public void addTcpListener(final TcpPacketListener theListener) { + _myTcpListener.add(theListener); + } + + + /** + * @param theListener TcpPacketListener + */ + public void removeTcpListener(final TcpPacketListener theListener) { + _myTcpListener.remove(theListener); + } + + + /** + * @param thePacket OscPacket + */ + public void send(final OscPacket thePacket) { + if (_myOscProperties.sendStatus() == false && _myOscProperties.networkProtocol() != OscProperties.TCP) { + Logger.printWarning("OscNetManager.send", "please specify a remote address. send(OscPacket theOscPacket) " + + "is only supported when there is a host specified in OscProperties."); + } + else { + try { + switch (_myOscProperties.networkProtocol()) { + case (OscProperties.UDP): + if (_myOscProperties.srsp()) { + _myUdpServer.send( + thePacket.getBytes(), + _myOscProperties.remoteAddress().inetaddress(), + _myOscProperties.remoteAddress().port()); + + } + else { + _myUdpClient.send( + thePacket.getBytes(), + _myOscProperties.remoteAddress().inetaddress(), + _myOscProperties.remoteAddress().port()); + } + break; + case (OscProperties.TCP): + if (isTcpServer) { + _myTcpServer.send(thePacket.getBytes()); + } + else if (isTcpClient) { + _myTcpClient.send(thePacket.getBytes()); + } + break; + case (OscProperties.MULTICAST): + _myMulticast.send(thePacket.getBytes()); + break; + } + } + catch (final NullPointerException e) { + Logger.printError("OscManager.send", "NullPointerException " + e); + } + } + } + + + public void send(final DatagramPacket thePacket) { + if (_myOscProperties.srsp()) { + _myUdpServer.send(thePacket); + } + else { + _myUdpClient.send(thePacket); + } + } + + + /** + * @param thePacket OscPacket + * @param theAddress String + * @param thePort int + */ + public void send(final OscPacket thePacket, final String theAddress, final int thePort) { + try { + switch (_myOscProperties.networkProtocol()) { + case (OscProperties.UDP): + if (_myOscProperties.srsp()) { + _myUdpServer.send(thePacket.getBytes(), theAddress, thePort); + } + else { + _myUdpClient.send(thePacket.getBytes(), theAddress, thePort); + } + break; + case (OscProperties.MULTICAST): + _myMulticast.send(thePacket.getBytes()); + break; + case (OscProperties.TCP): + Logger.printWarning( + "OscP5.send", + "send(OscPacket thePacket,String theAddress,int thePort) is not supported in TCP mode."); + break; + } + } + catch (final NullPointerException e) { + Logger.printError("OscP5.send", "NullPointerException " + e); + } + } + + + /** + * @param thePacket OscPacket + * @param theList OscHostList + */ + public void send(final OscPacket thePacket, final NetAddressList theList) { + switch (_myOscProperties.networkProtocol()) { + case (OscProperties.UDP): + final byte[] myBytes = thePacket.getBytes(); + final DatagramPacket myPacket = new DatagramPacket(myBytes, myBytes.length); + for (int i = 0; i < theList.list().size(); i++) { + myPacket.setAddress(theList.get(i).inetaddress()); + myPacket.setPort(theList.get(i).port()); + send(myPacket); + } + break; + case (OscProperties.TCP): + Logger.printWarning( + "OscP5.send", + "send(OscPacket thePacket,NetAddressList theList) is not supported in TCP mode."); + break; + } + } + + + /** + * @param thePacket OscPacket + * @param theHost NetAddress + */ + public void send(final OscPacket thePacket, final NetAddress theHost) { + switch (_myOscProperties.networkProtocol()) { + + case (OscProperties.UDP): + if (theHost.isvalid()) { + final byte[] myBytes = thePacket.getBytes(); + final DatagramPacket myPacket = new DatagramPacket(myBytes, myBytes.length); + myPacket.setAddress(theHost.inetaddress()); + myPacket.setPort(theHost.port()); + send(myPacket); + } + break; + case (OscProperties.TCP): + Logger.printWarning("OscP5.send", "send(OscPacket thePacket,NetAddress theHost) is not supported in TCP mode."); + break; + } + } + + + /** + * @param theAddrPattern String + * @param theArguments Object[] + */ + public void send(final String theAddrPattern, final Object[] theArguments) { + send(new OscMessage(theAddrPattern, theArguments)); + } + + + public void send(final String theAddrPattern, final Object[] theArguments, final String theAddress, final int thePort) { + send(new OscMessage(theAddrPattern, theArguments), theAddress, thePort); + } + + + public void send(final String theAddrPattern, final Object[] theArguments, final NetAddressList theList) { + send(new OscMessage(theAddrPattern, theArguments), theList); + } + + + public void send(final String theAddrPattern, final Object[] theArguments, final NetAddress theHost) { + send(new OscMessage(theAddrPattern, theArguments), theHost); + } + + + public void process(final DatagramPacket thePacket, final int thePort) { + for (int i = 0; i < _myUdpListener.size(); i++) { + _myUdpListener.get(i).process(thePacket, thePort); + } + } + + + public void process(final TcpPacket thePacket, final int thePort) { + for (int i = 0; i < _myTcpListener.size(); i++) { + _myTcpListener.get(i).process(thePacket, thePort); + } + } + + + public void remove(final AbstractTcpClient theClient) {} + + + public void status(final int theIndex) {} +} diff --git a/libraries/oscP5/src/oscP5/OscP5.java b/libraries/oscP5/src/oscP5/OscP5.java new file mode 100644 index 0000000..b2643dd --- /dev/null +++ b/libraries/oscP5/src/oscP5/OscP5.java @@ -0,0 +1,991 @@ +/** + * An OSC (Open Sound Control) library for processing. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package oscP5; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.SocketException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Vector; + +import netP5.AbstractTcpClient; +import netP5.Logger; +import netP5.NetAddress; +import netP5.NetAddressList; +import netP5.NetInfo; +import netP5.TcpClient; +import netP5.TcpPacket; +import netP5.TcpPacketListener; +import netP5.TcpServer; +import netP5.UdpPacketListener; + +/** + * oscP5 is an osc implementation for the programming environment processing. + * osc is the acronym for open sound control, a network protocol developed at + * cnmat, uc berkeley. open sound control is a protocol for communication among + * computers, sound synthesizers, and other multimedia devices that is optimized + * for modern networking technology and has been used in many application areas. + * for further specifications and application implementations please visit the + * official osc site. + * + * @usage Application + * @example oscP5sendReceive + * @related OscProperties + * @related OscMessage + * @related OscBundle + */ + +/** + * TODO add better error message handling for oscEvents, see this post + * http://forum.processing.org/topic/oscp5-major-problems-with-error-handling# 25080000000811163 + */ +public class OscP5 implements UdpPacketListener, TcpPacketListener { + + /* + * @TODO implement polling option to avoid threading and synchronization + * issues. check email from tom lieber. look into mutex objects. + * http://www.google.com/search?hl=en&q=mutex+java&btnG=Search + */ + + // protected ArrayList _myOscPlugList = new ArrayList(); + + protected HashMap> _myOscPlugMap = new HashMap>(); + + protected NetInfo _myNetInfo; + + private OscNetManager _myOscNetManager; + + protected final static int NONE = OscNetManager.NONE; + + public final static boolean ON = OscProperties.ON; + + public final static boolean OFF = OscProperties.OFF; + + /** + * a static variable used when creating an oscP5 instance with a sepcified network protocol. + */ + public final static int UDP = OscProperties.UDP; + + /** + * a static variable used when creating an oscP5 instance with a sepcified network protocol. + */ + public final static int MULTICAST = OscProperties.MULTICAST; + + /** + * a static variable used when creating an oscP5 instance with a sepcified network protocol. + */ + public final static int TCP = OscProperties.TCP; + + protected final Object parent; + + private OscProperties _myOscProperties; + + private Class _myParentClass; + + private Method _myEventMethod; + + private Class _myEventClass = OscMessage.class; + + private boolean isEventMethod; + + private boolean isBroadcast = false; + + private NetAddress _myBroadcastAddress; + + private boolean isOscIn = false; + + /** + * @invisible + */ + public static final String VERSION = "0.9.9"; + + + /** + * @param theParent Object + * @param theProperties OscProperties + * @usage Application + */ + public OscP5(final Object theParent, final OscProperties theProperties) { + welcome(); + parent = theParent; + + registerDispose(parent); + + _myOscProperties = theProperties; + _myOscNetManager = new OscNetManager(); + _myOscNetManager.start(_myOscProperties); + if (_myOscProperties.networkProtocol() == OscProperties.TCP) { + _myOscNetManager.addTcpListener(this); + } + else { + _myOscNetManager.addUdpListener(this); + } + isEventMethod = checkEventMethod(); + if (_myOscProperties.networkProtocol() == OscProperties.MULTICAST) { + Logger.printInfo("OscP5", "is joining a multicast group @ " + _myOscProperties.remoteAddress().address() + ":" + _myOscProperties.remoteAddress().port()); + } + else { + Logger.printInfo("OscP5", "is running. you (" + ip() + ") are listening @ port " + _myOscProperties.remoteAddress().port()); + } + } + + + /** + * @param theParent Object + * @param theAddress String + * @param thePort int + * @param theMode int + * @usage Application + */ + public OscP5(final Object theParent, final String theAddress, final int thePort, final int theMode) { + welcome(); + parent = theParent; + _myOscProperties = new OscProperties(); + + registerDispose(parent); + + switch (theMode) { + case (MULTICAST): + _myOscProperties.setNetworkProtocol(MULTICAST); + _myOscProperties.setRemoteAddress(theAddress, thePort); + _myOscProperties.setListeningPort(thePort); + _myOscNetManager = new OscNetManager(); + _myOscNetManager.start(_myOscProperties); + _myOscNetManager.addUdpListener(this); + Logger.printInfo("OscP5", "is joining a multicast group @ " + _myOscProperties.remoteAddress().address() + ":" + _myOscProperties.remoteAddress().port()); + break; + case (UDP): + _myOscProperties.setRemoteAddress(theAddress, thePort); + initUDP(thePort); + break; + case (TCP): + _myOscProperties.setNetworkProtocol(TCP); + _myOscProperties.setRemoteAddress(theAddress, thePort); + _myOscNetManager = new OscNetManager(); + _myOscNetManager.start(_myOscProperties); + _myOscNetManager.addTcpListener(this); + break; + } + isEventMethod = checkEventMethod(); + } + + + public OscP5(final Object theParent, final int theReceiveAtPort, final int theMode) { + welcome(); + parent = theParent; + + registerDispose(parent); + + _myOscProperties = new OscProperties(); + switch (theMode) { + case (UDP): + initUDP(theReceiveAtPort); + break; + case (TCP): + _myOscProperties.setNetworkProtocol(TCP); + _myOscProperties.setListeningPort(theReceiveAtPort); + _myOscNetManager = new OscNetManager(); + _myOscNetManager.start(_myOscProperties); + _myOscNetManager.addTcpListener(this); + break; + case (MULTICAST): + Logger.printWarning("OscP5", "please specify a multicast address. use " + "OscP5(Object theObject, String theMulticastAddress, int thePort, int theMode)"); + break; + } + isEventMethod = checkEventMethod(); + } + + + /** + * @param theParent Object + * @param theReceiveAtPort int + * @usage Application + */ + public OscP5(final Object theParent, final int theReceiveAtPort) { + welcome(); + parent = theParent; + + registerDispose(parent); + + initUDP(theReceiveAtPort); + isEventMethod = checkEventMethod(); + } + + + private void welcome() { + System.out.println("OscP5 " + VERSION + " " + "infos, comments, questions at http://www.sojamo.de/oscP5\n\n"); + } + + + private void registerDispose(Object theObject) { + try { + Object parent = null; + String child = "processing.core.PApplet"; + try { + Class childClass = Class.forName(child); + Class parentClass = Object.class; + + if (parentClass.isAssignableFrom(childClass)) { + parent = childClass.newInstance(); + parent = theObject; + } + } catch (Exception e) { + // System.out.println(e); + } + try { + Method method = parent.getClass().getMethod("registerDispose", Object.class); + try { + method.invoke(parent, new Object[] { this }); + } catch (IllegalArgumentException e) { + // System.out.println(e); + } catch (IllegalAccessException e) { + // System.out.println(e); + } catch (InvocationTargetException e) { + // System.out.println(e); + } + } catch (SecurityException e) { + // System.out.println("fail (1) " + e); + } catch (NoSuchMethodException e) { + // System.out.println("fail (2) " + e); + } + } catch (NullPointerException e) { + System.err.println("Register Dispose\n" + e); + } + } + + + private void initUDP(final int theReceiveAtPort) { + _myOscProperties = new OscProperties(); + _myOscProperties.setListeningPort(theReceiveAtPort); + _myOscNetManager = new OscNetManager(); + _myOscNetManager.start(_myOscProperties); + _myOscNetManager.addUdpListener(this); + Logger.printInfo("OscP5", "is running. you (" + ip() + ") are listening @ port " + theReceiveAtPort); + } + + + /** + * check which eventMethod exists in the Object oscP5 was started from. this is necessary for + * backwards compatibility for oscP5 because the previous parameterType for the eventMethod was + * OscIn and is now OscMessage. + * + * @return boolean + * @invisible + */ + private boolean checkEventMethod() { + _myParentClass = parent.getClass(); + try { + Method[] myMethods = _myParentClass.getDeclaredMethods(); + for (int i = 0; i < myMethods.length; i++) { + if (myMethods[i].getName().indexOf(_myOscProperties.eventMethod()) != -1) { + Class[] myClasses = myMethods[i].getParameterTypes(); + if (myClasses.length == 1) { + _myEventClass = myClasses[0]; + isOscIn = ((_myEventClass.toString()).indexOf("OscIn") != -1) ? true : false; + break; + } + } + } + + } catch (Throwable e) { + System.err.println(e); + } + + String tMethod = _myOscProperties.eventMethod(); + if (tMethod != null) { + try { + Class[] tClass = { _myEventClass }; + _myEventMethod = _myParentClass.getDeclaredMethod(tMethod, tClass); + _myEventMethod.setAccessible(true); + return true; + } catch (SecurityException e1) { + // e1.printStackTrace(); + Logger.printWarning("OscP5.plug", "### security issues in OscP5.checkEventMethod(). (this occures when running in applet mode)"); + } catch (NoSuchMethodException e1) { + } + } + // online fix, since an applet throws a security exception when calling + // setAccessible(true); + if (_myEventMethod != null) { + return true; + } + return false; + } + + + /** + * get the current version of oscP5. + * + * @return String + */ + public String version() { + return VERSION; + } + + + /** + * @invisible + */ + public void dispose() { + stop(); + } + + + public void addListener(OscEventListener theListener) { + _myOscProperties.listeners().add(theListener); + } + + + public void removeListener(OscEventListener theListener) { + _myOscProperties.listeners().remove(theListener); + } + + + public Vector listeners() { + return _myOscProperties.listeners(); + } + + + /** + * osc messages can be automatically forwarded to a specific method of an object. the plug + * method can be used to by-pass parsing raw osc messages - this job is done for you with the + * plug mechanism. you can also use the following array-types int[], float[], String[]. (but + * only as on single parameter e.g. somemethod(int[] theArray) {} ). + * + * @param theObject Object, can be any Object + * @param theMethodName String, the method name an osc message should be forwarded to + * @param theAddrPattern String, the address pattern of the osc message + * @param theTypeTag String + * @example oscP5plug + * @usage Application + */ + public void plug(final Object theObject, final String theMethodName, final String theAddrPattern, final String theTypeTag) { + final OscPlug myOscPlug = new OscPlug(); + myOscPlug.plug(theObject, theMethodName, theAddrPattern, theTypeTag); + // _myOscPlugList.add(myOscPlug); + if (_myOscPlugMap.containsKey(theAddrPattern)) { + _myOscPlugMap.get(theAddrPattern).add(myOscPlug); + } + else { + ArrayList myOscPlugList = new ArrayList(); + myOscPlugList.add(myOscPlug); + _myOscPlugMap.put(theAddrPattern, myOscPlugList); + } + } + + + /** + * @param theObject Object, can be any Object + * @param theMethodName String, the method name an osc message should be forwarded to + * @param theAddrPattern String, the address pattern of the osc message + * @example oscP5plug + * @usage Application + */ + public void plug(final Object theObject, final String theMethodName, final String theAddrPattern) { + final Class myClass = theObject.getClass(); + final Method[] myMethods = myClass.getDeclaredMethods(); + Class[] myParams = null; + for (int i = 0; i < myMethods.length; i++) { + String myTypetag = ""; + try { + myMethods[i].setAccessible(true); + } catch (Exception e) { + } + if ((myMethods[i].getName()).equals(theMethodName)) { + myParams = myMethods[i].getParameterTypes(); + OscPlug myOscPlug = new OscPlug(); + for (int j = 0; j < myParams.length; j++) { + myTypetag += myOscPlug.checkType(myParams[j].getName()); + } + + myOscPlug.plug(theObject, theMethodName, theAddrPattern, myTypetag); + // _myOscPlugList.add(myOscPlug); + if (_myOscPlugMap.containsKey(theAddrPattern)) { + _myOscPlugMap.get(theAddrPattern).add(myOscPlug); + } + else { + ArrayList myOscPlugList = new ArrayList(); + myOscPlugList.add(myOscPlug); + _myOscPlugMap.put(theAddrPattern, myOscPlugList); + } + + } + } + } + + + private void handleSystemMessage(final OscMessage theOscMessage) { + if (theOscMessage.addrPattern().startsWith("/sys/ping")) { + send("/sys/pong", new Object[0], _myBroadcastAddress); + } + else if (theOscMessage.addrPattern().startsWith("/sys/register")) { + if (theOscMessage.tcpConnection() != null) { + if (theOscMessage.checkTypetag("s")) { + theOscMessage.tcpConnection().setName(theOscMessage.get(0).stringValue()); + } + } + } + } + + + private void callMethod(final OscMessage theOscMessage) { + + if (theOscMessage.addrPattern().startsWith("/sys/")) { + handleSystemMessage(theOscMessage); + // finish this for oscbroadcaster + // return; + } + + // forward the message to all OscEventListeners + for (int i = listeners().size() - 1; i >= 0; i--) { + ((OscEventListener) listeners().get(i)).oscEvent(theOscMessage); + } + + /* check if the arguments can be forwarded as array */ + + if (theOscMessage.isArray) { + // for (int i = 0; i < _myOscPlugList.size(); i++) { + // OscPlug myPlug = ((OscPlug) _myOscPlugList.get(i)); + // if (myPlug.isArray && myPlug.checkMethod(theOscMessage, true)) { + // invoke(myPlug.getObject(), myPlug.getMethod(), + // theOscMessage.argsAsArray()); + // } + // } + + if (_myOscPlugMap.containsKey(theOscMessage.addrPattern())) { + ArrayList myOscPlugList = _myOscPlugMap.get(theOscMessage.addrPattern()); + for (int i = 0; i < myOscPlugList.size(); i++) { + OscPlug myPlug = (OscPlug) myOscPlugList.get(i); + if (myPlug.isArray && myPlug.checkMethod(theOscMessage, true)) { + // Should we set the following here? The old code did + // not: + // theOscMessage.isPlugged = true; + invoke(myPlug.getObject(), myPlug.getMethod(), theOscMessage.argsAsArray()); + } + } + } + + } + /* check if there is a plug method for the current message */ + // for (int i = 0; i < _myOscPlugList.size(); i++) { + // OscPlug myPlug = ((OscPlug) _myOscPlugList.get(i)); + // if (!myPlug.isArray && myPlug.checkMethod(theOscMessage, false)) { + // theOscMessage.isPlugged = true; + // invoke(myPlug.getObject(), myPlug.getMethod(), theOscMessage + // .arguments()); + // } + // } + + if (_myOscPlugMap.containsKey(theOscMessage.addrPattern())) { + ArrayList myOscPlugList = _myOscPlugMap.get(theOscMessage.addrPattern()); + for (int i = 0; i < myOscPlugList.size(); i++) { + OscPlug myPlug = (OscPlug) myOscPlugList.get(i); + if (!myPlug.isArray && myPlug.checkMethod(theOscMessage, false)) { + theOscMessage.isPlugged = true; + invoke(myPlug.getObject(), myPlug.getMethod(), theOscMessage.arguments()); + } + } + } + + /* if no plug method was detected, then use the default oscEvent mehtod */ + Logger.printDebug("OscP5.callMethod ", "" + isEventMethod); + if (isEventMethod) { + try { + if (isOscIn) { + invoke(parent, _myEventMethod, new Object[] { new OscIn(theOscMessage) }); + Logger.printDebug("OscP5.callMethod ", "invoking OscIn " + isEventMethod); + } + else { + invoke(parent, _myEventMethod, new Object[] { theOscMessage }); + Logger.printDebug("OscP5.callMethod ", "invoking OscMessage " + isEventMethod); + } + } catch (ClassCastException e) { + Logger.printError("OscHandler.callMethod", " ClassCastException." + e); + } + } + } + + + private void invoke(final Object theObject, final Method theMethod, final Object[] theArgs) { + try { + theMethod.invoke(theObject, theArgs); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + Logger.printError("OscP5", "ERROR. an error occured while forwarding an OscMessage\n " + "to a method in your program. please check your code for any \n" + + "possible errors that might occur in the method where incoming\n " + "OscMessages are parsed e.g. check for casting errors, possible\n " + + "nullpointers, array overflows ... .\n" + "method in charge : " + theMethod.getName() + " " + e); + } + } + + + /** + * incoming osc messages from an udp socket are parsed, processed and forwarded to the parent. + * + * @invisible + * @param thePacket DatagramPacket + * @param thePort int + */ + public void process(final DatagramPacket thePacket, final int thePort) { + synchronized (this) { + OscPacket p = OscPacket.parse(thePacket); + if (p.isValid()) { + if (p.type() == OscPacket.BUNDLE) { + for (int i = 0; i < ((OscBundle) p).size(); i++) { + callMethod(((OscBundle) p).getMessage(i)); + } + } + else { + callMethod((OscMessage) p); + } + } + notifyAll(); + } + } + + + /** + * @invisible + * @see netP5.TcpPacketListener#process(netP5.TcpPacket, int) + */ + public void process(final TcpPacket thePacket, final int thePort) { + synchronized (this) { + OscPacket p = OscPacket.parse(thePacket); + if (p.isValid()) { + if (p.type() == OscPacket.BUNDLE) { + for (int i = 0; i < ((OscBundle) p).size(); i++) { + callMethod(((OscBundle) p).getMessage(i)); + } + } + else { + callMethod((OscMessage) p); + } + } + notifyAll(); + } + } + + + /** + * @invisible + * @param theTcpClient AbstractTcpClient + */ + public void remove(AbstractTcpClient theTcpClient) { + } + + + /** + * @invisible + * @param theIndex int + */ + public void status(int theIndex) { + } + + + /** + * returns the current properties of oscP5. + * + * @return OscProperties + * @related OscProperties + * @usage Application + */ + public OscProperties properties() { + return _myOscProperties; + } + + + /** + * @invisible + * @return boolean + */ + public boolean isBroadcast() { + return isBroadcast; + } + + + /** + * @return String + * @invisible + */ + public String ip() { + return NetInfo.getHostAddress(); + } + + + /** + * oscP5 has a logging mechanism which prints out processes, warnings and errors into the + * console window. e.g. turn off the error log with setLogStatus(Logger.ERROR, Logger.OFF); + * + * @param theIndex int + * @param theValue int + * @usage Application + */ + public static void setLogStatus(final int theIndex, final int theValue) { + Logger.set(theIndex, theValue); + } + + + /** + * @param theValue + */ + public static void setLogStatus(final int theValue) { + for (int i = 0; i < Logger.ALL; i++) { + Logger.set(i, theValue); + } + } + + + /** + * set timeToLive of a multicast packet. + * + * @param theTTL int + */ + public void setTimeToLive(int theTTL) { + _myOscNetManager.setTimeToLive(theTTL); + } + + + /** + * @param theHost NetAddress + * @invisible + */ + public void disconnect(final NetAddress theHost) { + if (theHost.isvalid() && theHost.name.length() > 1) { + String myAddrPattern = "/sys/disconnect/" + theHost.name + "/" + theHost.port(); + send(myAddrPattern, new Object[0], theHost); + isBroadcast = false; + _myBroadcastAddress = null; + } + } + + + /** + * @param theNetAddress NetAddress + * @param theName String + * @param theArguments String[] + * @invisible + */ + public void connect(final NetAddress theNetAddress, final String theName, final String[] theArguments) { + if (theNetAddress.isvalid()) { + _myBroadcastAddress = theNetAddress; + _myBroadcastAddress.name = theName; + String myAddrPattern = "/sys/connect/" + theName + "/" + _myOscProperties.listeningPort(); + send(myAddrPattern, theArguments, _myBroadcastAddress); + isBroadcast = true; + } + } + + + /** + * netinfo() returns an instance of a NetInfo Object from which you can get LAN and WAN + * information. + * + * @return NetInfo + */ + public NetInfo netInfo() { + return _myNetInfo; + } + + + /** + * return the instance of the running TCP server if in TCP mode. + * + * @return TcpServer + */ + public TcpServer tcpServer() { + return _myOscNetManager.tcpServer(); + } + + + /** + * return the instance of the running TCP client if in TCP mode. + * + * @return TcpClient + */ + public TcpClient tcpClient() { + return _myOscNetManager.tcpClient(); + } + + + /** + * you can send osc packets in many different ways. see below and use the send method that fits + * your needs. + * + * + * @param thePacket OscPacket + * @param theNetAddress NetAddress + * @usage Application + */ + public void send(final OscPacket thePacket, final NetAddress theNetAddress) { + _myOscNetManager.send(thePacket, theNetAddress); + } + + + /** + * @param thePacket OscPacket + * @usage Application + * @example oscP5sendReceive + */ + public void send(final OscPacket thePacket) { + _myOscNetManager.send(thePacket); + } + + + /** + * @param thePacket OscPacket + * @param theNetAddressList NetAddressList + * @usage Application + */ + public void send(final OscPacket thePacket, final NetAddressList theNetAddressList) { + _myOscNetManager.send(thePacket, theNetAddressList); + } + + + /** + * @param theAddrPattern String + * @param theArguments Object[] + * @usage Application + */ + public void send(final String theAddrPattern, final Object[] theArguments) { + _myOscNetManager.send(theAddrPattern, theArguments); + } + + + /** + * @param theAddrPattern String + * @param theArguments Object[] + * @param theNetAddressList NetAddressList + * @usage Application + */ + public void send(final String theAddrPattern, final Object[] theArguments, final NetAddressList theNetAddressList) { + _myOscNetManager.send(theAddrPattern, theArguments, theNetAddressList); + } + + + /** + * @param theAddrPattern String + * @param theArguments Object[] + * @param theNetAddress NetAddress + * @usage Application + */ + public void send(final String theAddrPattern, final Object[] theArguments, final NetAddress theNetAddress) { + _myOscNetManager.send(theAddrPattern, theArguments, theNetAddress); + } + + + /** + * @param theAddrPattern String + * @param theArguments Object[] + * @param theNetAddress NetAddress + * @usage Application + */ + public void send(final String theAddrPattern, final Object[] theArguments, final String theAddress, int thePort) { + _myOscNetManager.send(theAddrPattern, theArguments, theAddress, thePort); + } + + + /** + * send to tcp client + * + * @param thePacket OscPacket + * @param theClient TcpClient + */ + public void send(final OscPacket thePacket, final TcpClient theClient) { + theClient.send(thePacket.getBytes()); + } + + + /** + * @param theAddrPattern String + * @param theArguments Object[] + * @param theClient TcpClient + */ + public void send(final String theAddrPattern, final Object[] theArguments, final TcpClient theClient) { + send(new OscMessage(theAddrPattern, theArguments), theClient); + } + + + /** + * the send method offers a lot of possibilities. have a look at the send documentation. + * + * @param thePacket OscPacket + * @param theIpAddress String + * @param thePort int + * @usage Application + * @deprecated + */ + public void send(final OscPacket thePacket, final String theIpAddress, final int thePort) { + _myOscNetManager.send(thePacket, theIpAddress, thePort); + } + + + /** + * stop oscP5 and close open Sockets. + */ + public void stop() { + Logger.printDebug("OscP5.stop", "starting to stop oscP5."); + _myOscNetManager.stop(); + Logger.printDebug("OscP5.stop", "stopping oscP5."); + } + + + /** + * a static method to send an OscMessage straight out of the box without having to instantiate + * oscP5. + * + * @param theOscMessage OscMessage + * @param theNetAddress NetAddress + * @example oscP5flush + */ + public static void flush(final OscMessage theOscMessage, final NetAddress theNetAddress) { + flush(theOscMessage.getBytes(), theNetAddress); + } + + + public static void flush(final OscPacket theOscPacket, final NetAddress theNetAddress) { + flush(theOscPacket.getBytes(), theNetAddress); + } + + + public static void flush(final String theAddrPattern, final Object[] theArguments, final NetAddress theNetAddress) { + flush((new OscMessage(theAddrPattern, theArguments)).getBytes(), theNetAddress); + } + + + public static void flush(final byte[] theBytes, final NetAddress theNetAddress) { + DatagramSocket mySocket; + try { + mySocket = new DatagramSocket(); + + DatagramPacket myPacket = new DatagramPacket(theBytes, theBytes.length, theNetAddress.inetaddress(), theNetAddress.port()); + mySocket.send(myPacket); + } catch (SocketException e) { + Logger.printError("OscP5.openSocket", "cant create socket " + e.getMessage()); + } catch (IOException e) { + Logger.printError("OscP5.openSocket", "cant create multicastSocket " + e.getMessage()); + } + } + + + /* + * DEPRECATED methods and constructors. + */ + + /** + * @param theBytes byte[] + * @param theAddress String + * @param thePort int + * @deprecated + */ + public static void flush(final byte[] theBytes, final String theAddress, final int thePort) { + flush(theBytes, new NetAddress(theAddress, thePort)); + } + + + /** + * @param theOscMessage OscMessage + * @param theAddress String + * @param thePort int + * @deprecated + */ + public static void flush(final OscMessage theOscMessage, final String theAddress, final int thePort) { + flush(theOscMessage.getBytes(), new NetAddress(theAddress, thePort)); + } + + + /** + * old version of constructor. still in here for backwards compatibility. + * + * @deprecated + * @invisible + */ + public OscP5(final Object theParent, final String theHost, final int theSendToPort, final int theReceiveAtPort, final String theMethodName) { + welcome(); + parent = theParent; + + registerDispose(parent); + + _myOscProperties = new OscProperties(); + _myOscProperties.setRemoteAddress(theHost, theSendToPort); + _myOscProperties.setListeningPort(theReceiveAtPort); + _myOscProperties.setEventMethod(theMethodName); + _myOscNetManager = new OscNetManager(); + _myOscNetManager.start(_myOscProperties); + _myOscNetManager.addUdpListener(this); + isEventMethod = checkEventMethod(); + } + + + /** + * @deprecated + * @param theAddrPattern String + * @return OscMessage + * @invisible + */ + public OscMessage newMsg(String theAddrPattern) { + return new OscMessage(theAddrPattern); + } + + + /** + * @deprecated + * @param theAddrPattern String + * @return OscMessage + * @invisible + */ + + public OscBundle newBundle() { + return new OscBundle(); + } + + + /** + * used by the monome library by jklabs + * + * @deprecated + * @invisible + */ + public void disconnectFromTEMP() { + } + + + /** + * @deprecated + * @param theParent Object + * @param theAddress String + * @param thePort int + */ + public OscP5(final Object theParent, final String theAddress, final int thePort) { + this(theParent, theAddress, thePort, OscProperties.MULTICAST); + } + +} diff --git a/libraries/oscP5/src/oscP5/OscPacket.java b/libraries/oscP5/src/oscP5/OscPacket.java new file mode 100644 index 0000000..4e9cc59 --- /dev/null +++ b/libraries/oscP5/src/oscP5/OscPacket.java @@ -0,0 +1,143 @@ +/** + * An OSC (Open Sound Control) library for processing. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package oscP5; + +import java.net.DatagramPacket; +import java.net.InetAddress; +import netP5.Bytes; +import netP5.NetAddress; +import netP5.TcpPacket; +import netP5.TcpClient; + +/** + * @invisible + */ +public abstract class OscPacket extends OscPatcher { + + protected static final int MESSAGE = 0; + + + protected static final int BUNDLE = 1; + + + protected InetAddress inetAddress; + + + protected String hostAddress; + + + protected int _myType; + + + protected TcpClient _myTcpClient = null; + + + protected int port; + + /** + * @invisible + */ + public OscPacket() {} + + + protected static OscPacket parse(DatagramPacket theDatagramPacket) { + if (evaluatePacket(theDatagramPacket.getData()) == MESSAGE) { + return new OscMessage(theDatagramPacket); + } else { + return new OscBundle(theDatagramPacket); + } + } + + + protected static OscPacket parse(TcpPacket theTcpPacket) { + if (evaluatePacket(theTcpPacket.getData()) == MESSAGE) { + return new OscMessage(theTcpPacket); + } else { + return new OscBundle(theTcpPacket); + } + } + + + private static int evaluatePacket(byte[] theBytes) { + return (Bytes.areEqual(OscBundle.BUNDLE_AS_BYTES, Bytes.copy(theBytes, 0, OscBundle.BUNDLE_AS_BYTES.length))) ? BUNDLE + : MESSAGE; + } + + + /** + * when in TCP mode, tcpConnection() returns the instance of the TcpClient that has sent the OscMessage. + * @return TcpClient + */ + public TcpClient tcpConnection() { + return _myTcpClient; + } + + + protected boolean isValid() { + return isValid; + } + + + protected int type() { + return _myType; + } + + + public int port() { + return port; + } + + + public NetAddress netAddress() { + return new NetAddress(inetAddress, port); + } + + + /** + * @deprecated + * @invisible + * @return NetAddress + */ + public NetAddress netaddress() { + return new NetAddress(inetAddress, port); + } + + + /** + * @return String + */ + public String address() { + return hostAddress; + } + + + /** + * @return byte[] + * @invisible + */ + public abstract byte[] getBytes(); + +} diff --git a/libraries/oscP5/src/oscP5/OscPatcher.java b/libraries/oscP5/src/oscP5/OscPatcher.java new file mode 100644 index 0000000..aade541 --- /dev/null +++ b/libraries/oscP5/src/oscP5/OscPatcher.java @@ -0,0 +1,245 @@ +/** + * An OSC (Open Sound Control) library for processing. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package oscP5; + +import java.net.InetAddress; +import java.util.ArrayList; +import netP5.Bytes; +import netP5.TcpClient; + +/** + * + * @invisible + */ +public abstract class OscPatcher { + + +protected static final byte ZEROBYTE = 0x00; + + protected static final byte KOMMA = 0x2c; + + protected static final long TIMETAG_OFFSET = 2208988800L; + + protected static final long TIEMTAG_NOW = 1; + + protected ArrayList messages; + + protected byte[] _myAddrPattern; + + protected int _myAddrInt = -1; + + protected byte[] _myTypetag = new byte[0]; + + protected byte[] _myData = new byte[0]; + + protected Object[] _myArguments; + + protected boolean isValid = false; + + protected long timetag = 1; + + protected boolean isArray = false; + + protected byte _myArrayType = 0X00; + + protected OscPatcher() { + } + + + protected int parseBundle(final byte[] theBytes, + final InetAddress theAddress, final int thePort, + final TcpClient theClient) { + if (theBytes.length > OscBundle.BUNDLE_HEADER_SIZE) { + timetag = (new Long(Bytes.toLong(Bytes.copy(theBytes, 8, 8)))).longValue(); + int myPosition = OscBundle.BUNDLE_HEADER_SIZE; + messages = new ArrayList(); + int myMessageLength = Bytes.toInt(Bytes.copy(theBytes, myPosition,4)); + while (myMessageLength != 0 && (myMessageLength % 4 == 0) + && myPosition < theBytes.length) { + myPosition += 4; + messages.add(new OscMessage(Bytes.copy(theBytes, myPosition,myMessageLength), + theAddress, + thePort, + timetag, + theClient)); + myPosition += myMessageLength; + if(myPosition >= theBytes.length) + break; + myMessageLength = Bytes.toInt(Bytes.copy(theBytes, myPosition,4)); + } + } + for (int i = 0; i < messages.size(); i++) { + if (!messages.get(i).isValid) { + messages.remove(messages.get(i)); + } + } + + if (messages.size() > 0) { + isValid = true; + } + return messages.size(); + } + + + protected void parseMessage(final byte[] theBytes) { + int myLength = theBytes.length; + int myIndex = 0; + myIndex = parseAddrPattern(theBytes, myLength, myIndex); + if (myIndex != -1) { + myIndex = parseTypetag(theBytes, myLength, myIndex); + } + if (myIndex != -1) { + _myData = Bytes.copy(theBytes, myIndex); + _myArguments = parseArguments(_myData); + isValid = true; + } + } + + + protected int parseAddrPattern(final byte[] theBytes, final int theLength, + final int theIndex) { + if (theLength > 4 && theBytes[4] == KOMMA) { + _myAddrInt = Bytes.toInt(Bytes.copy(theBytes, 0, 4)); + } + for (int i = theIndex; i < theLength; i++) { + if (theBytes[i] == ZEROBYTE) { + _myAddrPattern = Bytes.copy(theBytes, theIndex, i); + return i + align(i); + } + } + return -1; + } + + + protected int parseTypetag(final byte[] theBytes, final int theLength, + int theIndex) { + if (theBytes[theIndex] == KOMMA) { + theIndex++; + for (int i = theIndex; i < theLength; i++) { + if (theBytes[i] == ZEROBYTE) { + _myTypetag = Bytes.copy(theBytes, theIndex, i - theIndex); + return i + align(i); + } + } + } + return -1; + } + + + /** + * cast the arguments passed with the incoming osc message and store them in + * an object array. + * + * @param theBytes + * @return + */ + protected Object[] parseArguments(final byte[] theBytes) { + Object[] myArguments = new Object[0]; + int myTagIndex = 0; + int myIndex = 0; + myArguments = new Object[_myTypetag.length]; + isArray = (_myTypetag.length > 0) ? true : false; + while (myTagIndex < _myTypetag.length) { + /* check if we still save the arguments as an array */ + if (myTagIndex == 0) { + _myArrayType = _myTypetag[myTagIndex]; + } else { + if (_myTypetag[myTagIndex] != _myArrayType) { + isArray = false; + } + } + switch (_myTypetag[myTagIndex]) { + case (0x63): // char c + myArguments[myTagIndex] = (new Character((char) (Bytes + .toInt(Bytes.copy(theBytes, myIndex, 4))))); + myIndex += 4; + break; + case (0x69): // int i + myArguments[myTagIndex] = (new Integer(Bytes.toInt(Bytes.copy( + theBytes, myIndex, 4)))); + myIndex += 4; + break; + case (0x66): // float f + myArguments[myTagIndex] = (new Float(Bytes.toFloat(Bytes.copy( + theBytes, myIndex, 4)))); + myIndex += 4; + + break; + case (0x6c): // long l + case (0x68): // long h + myArguments[myTagIndex] = (new Long(Bytes.toLong(Bytes.copy( + theBytes, myIndex, 8)))); + myIndex += 8; + break; + case (0x64): // double d + myArguments[myTagIndex] = (new Double(Bytes.toDouble(Bytes + .copy(theBytes, myIndex, 8)))); + myIndex += 8; + break; + case (0x53): // Symbol S + case (0x73): // String s + int newIndex = myIndex; + StringBuffer stringBuffer = new StringBuffer(); + + stringLoop: + do { + if (theBytes[newIndex] == 0x00) { + break stringLoop; + } else { + stringBuffer.append((char) theBytes[newIndex]); + } + newIndex++; + } while (newIndex < theBytes.length); + + myArguments[myTagIndex] = (stringBuffer.toString()); + myIndex = newIndex + align(newIndex); + break; + case 0x62: // byte[] b - blob + int myLen = Bytes.toInt(Bytes.copy(theBytes, myIndex, 4)); + myIndex += 4; + myArguments[myTagIndex] = Bytes.copy(theBytes, myIndex, myLen); + myIndex += myLen + (align(myLen) % 4); + break; + case 0x6d: // midi m + myArguments[myTagIndex] = Bytes.copy(theBytes, myIndex, 4); + myIndex += 4; + break; + /* + * no arguments for typetags T,F,N T = true F = false N = false + */ + } + myTagIndex++; + } + _myData = Bytes.copy(_myData, 0, myIndex); + return myArguments; + } + + + protected static int align(int theInt) { + return (4 - (theInt % 4)); + } + +} \ No newline at end of file diff --git a/libraries/oscP5/src/oscP5/OscPlug.java b/libraries/oscP5/src/oscP5/OscPlug.java new file mode 100644 index 0000000..1fcec89 --- /dev/null +++ b/libraries/oscP5/src/oscP5/OscPlug.java @@ -0,0 +1,258 @@ +/** + * An OSC (Open Sound Control) library for processing. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package oscP5; + +import java.lang.reflect.Method; +import netP5.Logger; + +/** + * + * @invisible + */ +public class OscPlug { + + private boolean _isValid = true; + + private String _myTypetag = ""; + + private String _myAddrPattern = ""; + + private String _myPattern = ""; + + private String _myMethodName; + + private Object _myObject; + + public Method method = null; + + private int _myChecker = 0; + + protected boolean isArray = false; + + private static final int CHECK_ADDRPATTERN_TYPETAG = 0; + + private static final int CHECK_ADDRPATTERN = 1; + + private static final int CHECK_TYPETAG = 2; + + public void plug(final Object theObject, final String theMethodName, + final String theAddrPattern) { + _myObject = theObject; + _myMethodName = theMethodName; + _myAddrPattern = theAddrPattern; + _myChecker = CHECK_ADDRPATTERN_TYPETAG; + if (_myMethodName != null && _myMethodName.length() > 0) { + Class myClass = theObject.getClass(); + Class[] myParams = null; + Method[] myMethods = myClass.getMethods(); + _myTypetag = ""; + for (int i = 0; i < myMethods.length; i++) { + if ((myMethods[i].getName()).equals(_myMethodName)) { + myParams = myMethods[i].getParameterTypes(); + for (int j = 0; j < myParams.length; j++) { + _myTypetag += checkType(myParams[j].getName()); + } + break; + } + } + if (myParams != null) { + makeMethod(theObject.getClass(), myParams); + } else { + Logger.printWarning("OscPlug.plug()", + "no arguments found for method " + _myMethodName); + } + } + } + + public void plug(final Object theObject, final String theMethodName, + final String theAddrPattern, final String theTypetag) { + _myObject = theObject; + _myMethodName = theMethodName; + _myAddrPattern = theAddrPattern; + _myTypetag = theTypetag; + _myChecker = CHECK_ADDRPATTERN_TYPETAG; + + if (_myMethodName != null && _myMethodName.length() > 0) { + int tLen = _myTypetag.length(); + Class[] myParams; + if (tLen > 0) { + myParams = getArgs(_myTypetag); + } else { + myParams = null; + } + + if (_isValid) { + makeMethod(theObject.getClass(), myParams); + } + } + } + + public Object getObject() { + return _myObject; + } + + private void makeMethod(final Class theObjectsClass, final Class[] theClass) { + try { + method = theObjectsClass.getDeclaredMethod(_myMethodName, theClass); + _myPattern = _myAddrPattern + _myTypetag; + method.setAccessible(true); + Logger.printProcess("OscPlug", "plugging " + theObjectsClass + + " | " + "addrPattern:" + _myAddrPattern + " typetag:" + + _myTypetag + " method:" + _myMethodName); + + } catch (Exception e) { + final Class theObjecsSuperClass = theObjectsClass.getSuperclass(); + if (theObjecsSuperClass.equals(Object.class)) { + if (theObjectsClass.getName().equals("java.awt.Component") == false) { // applet fix. + Logger.printError("OscPlug", "method " + + theObjectsClass.getName() + + " does not exist in your code."); + } + } else { + makeMethod(theObjecsSuperClass, theClass); + } + } + return; + } + + public boolean checkMethod(final OscMessage theOscMessage, + final boolean isArray) { + String myTypetag; + /* + * if theFlag is true and the arguments of theOscmessage can be + * represented as an array of the same type, then only fetch the first + * character of the typetag, otherwise use the full typetag. + */ + if (isArray) { + myTypetag = "" + theOscMessage.typetag().charAt(0); + } else { + myTypetag = theOscMessage.typetag(); + } + switch (_myChecker) { + case (CHECK_ADDRPATTERN_TYPETAG): + String thePattern = theOscMessage.addrPattern() + myTypetag; + return thePattern.equals(_myPattern); + case (CHECK_ADDRPATTERN): + return (theOscMessage.addrPattern().equals(_myAddrPattern)); + case (CHECK_TYPETAG): + return (myTypetag.equals(_myTypetag)); + default: + return false; + } + } + + public Method getMethod() { + return method; + } + + + public String checkType(final String theName) { + if (theName.equals("int")) { + return "i"; + } else if (theName.equals("float")) { + return "f"; + } else if (theName.equals("java.lang.String")) { + return "s"; + } else if (theName.equals("[Ljava.lang.String;")) { + isArray = true; + return "s"; + } + + else if (theName.equals("char")) { + return "c"; + } else if (theName.equals("[B")) { + return "b"; + } else if (theName.equals("[F")) { + isArray = true; + return "f"; + } else if (theName.equals("[I")) { + isArray = true; + return "i"; + } + + else if (theName.equals("double")) { + return "d"; + } else if (theName.equals("boolean")) { + return "T"; + } else if (theName.equals("long")) { + return "h"; + } + return ""; + } + + private Class[] getArgs(final String theArgs) { + char[] tChar = theArgs.toCharArray(); + int tLen = theArgs.length(); + Class[] tClass = new Class[tLen]; + for (int i = 0; i < tLen; i++) { + switch (tChar[i]) { + case ('i'): + tClass[i] = (isArray == true) ? int[].class : int.class; + break; + case ('S'): + case ('s'): + tClass[i] = (isArray == true) ? String[].class : String.class; + break; + case ('f'): + tClass[i] = (isArray == true) ? float[].class : float.class; + break; + case ('d'): + tClass[i] = double.class; + break; + case ('c'): + tClass[i] = char.class; + break; + case ('h'): + case ('l'): + tClass[i] = long.class; + break; + case ('T'): + tClass[i] = boolean.class; + break; + case ('F'): + tClass[i] = boolean.class; + break; + case ('b'): + tClass[i] = byte[].class; + break; + case ('o'): + _myChecker = CHECK_ADDRPATTERN; + tClass = new Class[] { Object[].class }; + break; + + default: + _isValid = false; + break; + } + } + if (!_isValid) { + tClass = null; + System.out.println("ERROR could't plug method " + _myMethodName); + } + return tClass; + } + +} diff --git a/libraries/oscP5/src/oscP5/OscProperties.java b/libraries/oscP5/src/oscP5/OscProperties.java new file mode 100644 index 0000000..281eb1f --- /dev/null +++ b/libraries/oscP5/src/oscP5/OscProperties.java @@ -0,0 +1,319 @@ +/** + * An OSC (Open Sound Control) library for processing. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package oscP5; + + +import netP5.Logger; +import netP5.NetAddress; +import java.util.Vector; + +/** + * osc properties are used to start oscP5 with more specific settings. + * osc properties have to be passed to oscP5 in the constructor when + * starting a new instance of oscP5. + * @related OscP5 + * @example oscP5properties + */ +public class OscProperties { + + public static final boolean ON = true; + + public static final boolean OFF = false; + + /** + * @related setNetworkProtocol ( ) + */ + public static final int UDP = 0; + + /** + * @related setNetworkProtocol ( ) + */ + public static final int MULTICAST = 1; + + + /** + * @related setNetworkProtocol ( ) + */ + public static final int TCP = 2; + + + protected static final String[] _myProtocols = {"udp", "tcp", "multicast"}; + + protected boolean isLocked = false; + + protected final Vector listeners; + + private NetAddress _myRemoteAddress = new NetAddress("", 0); + + private int _myListeningPort = 0; + + private int _myDatagramSize = 1536; // common MTU + + protected String _myDefaultEventMethodName = "oscEvent"; + + private int _myNetworkProtocol = UDP; + + private boolean _mySendStatus = false; + + private boolean _mySRSP = OFF; // (S)end (R)eceive (S)ame (P)ort + + public OscProperties(OscEventListener theParent) { + this(); + listeners.add(theParent); + } + + + + /** + * create a new OscProperties Object. + */ + public OscProperties() { + listeners = new Vector(); + } + + + + /** + * + * @return OscEventListener + * @invisible + */ + public Vector listeners() { + return listeners; + } + + + + /** + * + * @return boolean + * @related OscProperties + * @invisible + */ + public boolean sendStatus() { + return _mySendStatus; + } + + + + /** + * set the remote host address. set ip address and port of the host + * message should be sent to. + * @param theHostAddress String + * @param thePort int + * @related OscProperties + */ + public void setRemoteAddress(final String theHostAddress, final int thePort) { + _myRemoteAddress = new NetAddress(theHostAddress, thePort); + _mySendStatus = _myRemoteAddress.isvalid(); + } + + /** + * set the remote host address. set ip address and port of the host + * message should be sent to. + * @param theNetAddress NetAddress + * @related OscProperties + */ + public void setRemoteAddress(NetAddress theNetAddress) { + _myRemoteAddress = theNetAddress; + _mySendStatus = _myRemoteAddress.isvalid(); + } + + + /** + *set port number you are listening for incoming osc packets. + * @param thePort int + * @related OscProperties + */ + public void setListeningPort(final int thePort) { + _myListeningPort = thePort; + } + + + + /** + * set the size of the datagrampacket byte buffer. + * the default size is 1536 bytes. + * @param theSize int + * @related OscProperties + */ + public void setDatagramSize(final int theSize) { + if (!isLocked) { + _myDatagramSize = theSize; + } + else { + Logger.printWarning("OscProperties.setDatagramSize", + "datagram size can only be set before initializing oscP5\ncurrent datagram size is " + + _myDatagramSize); + } + } + + + + /** + * set the name of the default event method. + * the event method is the method to which incoming osc messages + * are forwarded. the default name for the event method is + * "oscEvent" + * @param theEventMethod String + * @related OscProperties + */ + public void setEventMethod(final String theEventMethod) { + _myDefaultEventMethodName = theEventMethod; + } + + + + /** + * set the network protocol over which osc messages are transmitted. + * options are OscProperties.UDP and OscProperties.MULTICAST + * the network protocol can only be set before initializing + * oscP5. + * @param theProtocol int + * @related OscProperties + * @related UDP + * @related TCP + * @related MULTICAST + * @related networkProtocol ( ) + */ + public void setNetworkProtocol(final int theProtocol) { + if (!isLocked) { + if (theProtocol > 2) { + Logger.printWarning("OscProperties.setNetworkProtocol", + "not in the range of supported Network protocols. the network protocol defaults to UDP"); + } + else { + _myNetworkProtocol = theProtocol; + } + } + else { + Logger.printWarning("OscProperties.setNetworkProtocol", + "network protocol can only be set before initializing oscP5."); + } + } + + + + /** + * SRSP stand for Send and Receive on Same Port. + * by default osc packets are not received and sent by the same port. + * if you need to send and receive on the same port call + * setSRSP(OscProperties.ON) + * @param theFlag boolean + * @related OscProperties + */ + public void setSRSP(final boolean theFlag) { + _mySRSP = theFlag; + } + + + + /** + * you can send and receive at the same port while on a udp con + * @return boolean + * @related OscProperties + */ + public boolean srsp() { + return _mySRSP; + } + + + + /** + * returns the port number currently used to receive osc packets. + * @return int + * @related OscProperties + */ + public int listeningPort() { + return _myListeningPort; + } + + + + /** + * returns a NetAddress of the remote host you are sending + * osc packets to. by default this is null. + * @return NetAddress + * @related OscProperties + */ + public NetAddress remoteAddress() { + return _myRemoteAddress; + } + + + + /** + * returns the current size of the datagram bytebuffer. + * @return int + * @related OscProperties + */ + public int datagramSize() { + return _myDatagramSize; + } + + + + /** + * + * @return String + * @related OscProperties + */ + public String eventMethod() { + return _myDefaultEventMethodName; + } + + + + /** + * returns the network protocol being used to transmit osc packets. returns an int. + * 0 (UDP), 1 (MULTICAST), 2 (TCP) + * @return int + * @related OscProperties + */ + public int networkProtocol() { + return _myNetworkProtocol; + } + + + + /** + * prints out the current osc properties settings. + * @return String + * @related OscProperties + */ + public String toString() { + String s = "\nnetwork protocol: " + (_myProtocols[_myNetworkProtocol]) + + "\n"; + s += "host: " + ((_myRemoteAddress.address()!=null) ? _myRemoteAddress.address():"host address not set.") + "\n"; + s += "sendToPort: " + _myRemoteAddress.port() + "\n"; + s += "receiveAtPort: " + listeningPort() + "\n"; + s += "datagramSize: " + _myDatagramSize + "\n"; + s += "event Method: " + _myDefaultEventMethodName + "\n"; + s += "(S)end(R)eceive(S)ame(P)ort: " + this._mySRSP + "\n\n"; + return s; + } + +} diff --git a/libraries/oscP5/src/oscP5/OscStatus.java b/libraries/oscP5/src/oscP5/OscStatus.java new file mode 100644 index 0000000..9744a98 --- /dev/null +++ b/libraries/oscP5/src/oscP5/OscStatus.java @@ -0,0 +1,63 @@ +/** + * An OSC (Open Sound Control) library for processing. + * + * (c) 2004-2012 + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General + * Public License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA + * + * @author Andreas Schlegel http://www.sojamo.de + * @modified 12/23/2012 + * @version 0.9.9 + */ + +package oscP5; + +public class OscStatus { + + + public static int ERROR = -1; + + public static int DEFAULT = 0; + + public static int CONNECTION_CLOSED = 1; + + public static int CONNECTION_REFUSED = 2; + + public static int CONNECTION_TERMINATED = 4; + + public static int CONNECTION_FAILED = 8; + + public static int SERVER_CLOSED = 16; + + public static int CLIENT_CLOSED = 32; + + public static int SEND_FAILED = 64; + + public static int OSCP5_CLOSED = 1024; + + private int _myIndex = DEFAULT; + + + public OscStatus(int theIndex) { + _myIndex = theIndex; + } + + + public int id() { + return _myIndex; + } + +} -- cgit v1.2.3-70-g09d2