Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

How to reconnect/stop OscP5 TCPIP ?

$
0
0

Hello, i want to stop and start new connection, but oscP5tcpClient.stop(); not working...

CLIENT

 import oscP5.*;
 OscP5 oscP5tcpClient;
 OscMessage m;

 String input;

 void setup() {
   size(500, 500);
   oscP5tcpClient = new OscP5(this, "localhost", 29922, OscP5.TCP);
   send("HELLO");
   reconnect();
 }

 void draw() {
 }

 void mouseReleased() {
   reconnect();
 }

 void reconnect() {
   oscP5tcpClient.stop();
   println("STOPPED");
   oscP5tcpClient = new OscP5(this, "localhost", 29922, OscP5.TCP);
   send("HELLO");
 }

 void oscEvent(OscMessage theMessage) {
   input = theMessage.addrPattern();
 }

 void send(String message) {
   oscP5tcpClient.send(message, new Object[] {new Integer(1)});
 }

SERVER

 import oscP5.*;
 import netP5.*;
 OscP5 oscP5tcpServer;
 NetAddress myServerAddress;

 String input;

 void setup() {
   oscP5tcpServer = new OscP5(this, 29922, OscP5.TCP);
 }

 void oscEvent(OscMessage theMessage) {
   input = theMessage.addrPattern();
   println(input);
 }

Viewing all articles
Browse latest Browse all 2896

Trending Articles