|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.ObjectoscP5.OscP5
public class OscP5
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 int |
MULTICAST
a static variable used when creating an oscP5 instance with a sepcified network protocol. |
static boolean |
OFF
|
static boolean |
ON
|
static int |
TCP
a static variable used when creating an oscP5 instance with a sepcified network protocol. |
static int |
UDP
a static variable used when creating an oscP5 instance with a sepcified network protocol. |
static String |
VERSION
|
| 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 | |
|---|---|
void |
addListener(OscEventListener theListener)
|
void |
connect(NetAddress theNetAddress,
String theName,
String[] theArguments)
|
void |
disconnect(NetAddress theHost)
|
void |
disconnectFromTEMP()
Deprecated. |
void |
dispose()
|
static void |
flush(byte[] theBytes,
NetAddress theNetAddress)
|
static void |
flush(byte[] theBytes,
String theAddress,
int thePort)
Deprecated. |
static void |
flush(OscMessage theOscMessage,
NetAddress theNetAddress)
a static method to send an OscMessage straight out of the box without having to instantiate oscP5. |
static void |
flush(OscMessage theOscMessage,
String theAddress,
int thePort)
Deprecated. |
static void |
flush(OscPacket theOscPacket,
NetAddress theNetAddress)
|
static void |
flush(String theAddrPattern,
Object[] theArguments,
NetAddress theNetAddress)
|
String |
ip()
|
boolean |
isBroadcast()
|
Vector<OscEventListener> |
listeners()
|
NetInfo |
netInfo()
netinfo() returns an instance of a NetInfo Object from which you can get LAN and WAN information. |
OscBundle |
newBundle()
Deprecated. |
OscMessage |
newMsg(String theAddrPattern)
Deprecated. |
void |
plug(Object theObject,
String theMethodName,
String theAddrPattern)
|
void |
plug(Object theObject,
String theMethodName,
String theAddrPattern,
String theTypeTag)
osc messages can be automatically forwarded to a specific method of an object. |
void |
process(DatagramPacket thePacket,
int thePort)
incoming osc messages from an udp socket are parsed, processed and forwarded to the parent. |
void |
process(TcpPacket thePacket,
int thePort)
|
OscProperties |
properties()
returns the current properties of oscP5. |
void |
remove(AbstractTcpClient theTcpClient)
|
void |
removeListener(OscEventListener theListener)
|
void |
send(OscPacket thePacket)
|
void |
send(OscPacket thePacket,
NetAddress theNetAddress)
you can send osc packets in many different ways. |
void |
send(OscPacket thePacket,
NetAddressList theNetAddressList)
|
void |
send(OscPacket thePacket,
String theIpAddress,
int thePort)
Deprecated. |
void |
send(OscPacket thePacket,
TcpClient theClient)
send to tcp client |
void |
send(String theAddrPattern,
Object[] theArguments)
|
void |
send(String theAddrPattern,
Object[] theArguments,
NetAddress theNetAddress)
|
void |
send(String theAddrPattern,
Object[] theArguments,
NetAddressList theNetAddressList)
|
void |
send(String theAddrPattern,
Object[] theArguments,
String theAddress,
int thePort)
|
void |
send(String theAddrPattern,
Object[] theArguments,
TcpClient theClient)
|
static void |
setLogStatus(int theValue)
|
static void |
setLogStatus(int theIndex,
int theValue)
oscP5 has a logging mechanism which prints out processes, warnings and errors into the console window. |
void |
setTimeToLive(int theTTL)
set timeToLive of a multicast packet. |
void |
status(int theIndex)
|
void |
stop()
stop oscP5 and close open Sockets. |
TcpClient |
tcpClient()
return the instance of the running TCP client if in TCP mode. |
TcpServer |
tcpServer()
return the instance of the running TCP server if in TCP mode. |
String |
version()
get the current version of oscP5. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final boolean ON
public static final boolean OFF
public static final int UDP
public static final int MULTICAST
public static final int TCP
public static final String VERSION
| Constructor Detail |
|---|
public OscP5(Object theParent,
OscProperties theProperties)
theParent - ObjecttheProperties - OscProperties
public OscP5(Object theParent,
String theAddress,
int thePort,
int theMode)
theParent - ObjecttheAddress - StringthePort - inttheMode - int
public OscP5(Object theParent,
int theReceiveAtPort,
int theMode)
public OscP5(Object theParent,
int theReceiveAtPort)
theParent - ObjecttheReceiveAtPort - int
public OscP5(Object theParent,
String theHost,
int theSendToPort,
int theReceiveAtPort,
String theMethodName)
public OscP5(Object theParent,
String theAddress,
int thePort)
theParent - ObjecttheAddress - StringthePort - int| Method Detail |
|---|
public String version()
public void dispose()
public void addListener(OscEventListener theListener)
public void removeListener(OscEventListener theListener)
public Vector<OscEventListener> listeners()
public void plug(Object theObject,
String theMethodName,
String theAddrPattern,
String theTypeTag)
theObject - Object, can be any ObjecttheMethodName - String, the method name an osc message should be forwarded totheAddrPattern - String, the address pattern of the osc messagetheTypeTag - String
/**
* 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());
}
}
public void plug(Object theObject,
String theMethodName,
String theAddrPattern)
theObject - Object, can be any ObjecttheMethodName - String, the method name an osc message should be forwarded totheAddrPattern - String, the address pattern of the osc message
/**
* 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());
}
}
public void process(DatagramPacket thePacket,
int thePort)
process in interface UdpPacketListenerthePacket - DatagramPacketthePort - int
public void process(TcpPacket thePacket,
int thePort)
process in interface TcpPacketListenerTcpPacketListener.process(netP5.TcpPacket, int)public void remove(AbstractTcpClient theTcpClient)
remove in interface TcpPacketListenertheTcpClient - AbstractTcpClientpublic void status(int theIndex)
status in interface TcpPacketListenertheIndex - intpublic OscProperties properties()
public boolean isBroadcast()
public String ip()
public static void setLogStatus(int theIndex,
int theValue)
theIndex - inttheValue - intpublic static void setLogStatus(int theValue)
theValue - public void setTimeToLive(int theTTL)
theTTL - intpublic void disconnect(NetAddress theHost)
theHost - NetAddress
public void connect(NetAddress theNetAddress,
String theName,
String[] theArguments)
theNetAddress - NetAddresstheName - StringtheArguments - String[]public NetInfo netInfo()
public TcpServer tcpServer()
public TcpClient tcpClient()
public void send(OscPacket thePacket,
NetAddress theNetAddress)
thePacket - OscPackettheNetAddress - NetAddresspublic void send(OscPacket thePacket)
thePacket - OscPacket
/**
* 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());
}
public void send(OscPacket thePacket,
NetAddressList theNetAddressList)
thePacket - OscPackettheNetAddressList - NetAddressList
public void send(String theAddrPattern,
Object[] theArguments)
theAddrPattern - StringtheArguments - Object[]
public void send(String theAddrPattern,
Object[] theArguments,
NetAddressList theNetAddressList)
theAddrPattern - StringtheArguments - Object[]theNetAddressList - NetAddressList
public void send(String theAddrPattern,
Object[] theArguments,
NetAddress theNetAddress)
theAddrPattern - StringtheArguments - Object[]theNetAddress - NetAddress
public void send(String theAddrPattern,
Object[] theArguments,
String theAddress,
int thePort)
theAddrPattern - StringtheArguments - Object[]theNetAddress - NetAddress
public void send(OscPacket thePacket,
TcpClient theClient)
thePacket - OscPackettheClient - TcpClient
public void send(String theAddrPattern,
Object[] theArguments,
TcpClient theClient)
theAddrPattern - StringtheArguments - Object[]theClient - TcpClient
public void send(OscPacket thePacket,
String theIpAddress,
int thePort)
thePacket - OscPackettheIpAddress - StringthePort - intpublic void stop()
public static void flush(OscMessage theOscMessage,
NetAddress theNetAddress)
theOscMessage - OscMessagetheNetAddress - NetAddress
/**
* 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);
}
public static void flush(OscPacket theOscPacket,
NetAddress theNetAddress)
public static void flush(String theAddrPattern,
Object[] theArguments,
NetAddress theNetAddress)
public static void flush(byte[] theBytes,
NetAddress theNetAddress)
public static void flush(byte[] theBytes,
String theAddress,
int thePort)
theBytes - byte[]theAddress - StringthePort - int
public static void flush(OscMessage theOscMessage,
String theAddress,
int thePort)
theOscMessage - OscMessagetheAddress - StringthePort - intpublic OscMessage newMsg(String theAddrPattern)
theAddrPattern - String
public OscBundle newBundle()
theAddrPattern - String
public void disconnectFromTEMP()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||