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 & HelpSound,  Music Libraries › Presumably simple oscP5 question
Page Index Toggle Pages: 1
Presumably simple oscP5 question (Read 1456 times)
Presumably simple oscP5 question
May 4th, 2010, 12:00am
 
Hi,

I'm pretty sure this is trivial, but I've only just begun playing with Processing and oscP5.

I'd like to have an OSC message sent whenever I close the Processing sketch (to let the receiving end know the connection is about to be closed, for instance).

How would I do that?
Re: Presumably simple oscP5 question
Reply #1 - May 5th, 2010, 12:55am
 
I guess it's not so trivial then. Well, at least it makes me feel better about not being able to figure it out by myself.
Re: Presumably simple oscP5 question
Reply #2 - May 5th, 2010, 1:16am
 
you can try adding the following to your sketch:

Code:

void stop() {
 // the remote address of the receiving end
 NetAddress myRemoteLocation = new NetAddress("127.0.0.1",12001);
 OscMessage myMessage = new OscMessage("/connection/closed");
 myMessage.add("i stopped running.");
 oscP5.send(myMessage, myRemoteLocation);
 super.stop();
}


stop() is called whenever a sketch has stopped, dont forget to add super.stop() to call PApplet's stop() function for cleaning up.
best,
andreas
Re: Presumably simple oscP5 question
Reply #3 - May 5th, 2010, 2:00am
 
Excellent, thank you very much.
Page Index Toggle Pages: 1