We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › Osc Protocol
Page Index Toggle Pages: 1
Osc Protocol (Read 328 times)
Osc Protocol
Jan 8th, 2009, 5:32pm
 
Hello, I want to understand the protocol osc, got an exemple on the site of oscp5(http://www.sojamo.de/libraries/oscP5/examples/oscP5message/oscP5message.pde) to apply on a small example(Rotation of a cube), I have done two separate file a client and a server program but when
I run the two programs it gives me the following error:
NullPointerException
Exception in thread "Animation Thread" java.lang.NullPointerException

at client.mousePressed(client.java:50)

at processing.core.PApplet.handleMouseEvent(PApplet.java:1585)

at processing.core.PApplet.dequeueMouseEvents(PApplet.java:1522)

at processing.core.PApplet.handleDraw(PApplet.java:1417)

at processing.core.PApplet.run(PApplet.java:1311)

at java.lang.Thread.run(Unknown Source)

Here is the code of client and server:
Client code:

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

void setup() {
 size(400,400);
 frameRate(25);
 
 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);
}

Server code:

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

void setup() {
 size(400,400);
 frameRate(25);
 
 oscP5 = new OscP5(this,12000);
 

}
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());
}

Page Index Toggle Pages: 1