Server and Client > if(sendMessages=="hello") {any...} //doesnt working :(

edited June 2017 in Library Questions

code:

import processing.net.*; 
Client myClient; 
String inString;
byte interesting = 10;

void setup() { 
  size (300, 100);
  myClient = new Client(this, "127.0.0.1", 12345); 
} 

void draw() { 
  
  if (myClient.available() > 0) { 
    background(0); 
    inString = myClient.readStringUntil(interesting); 
    println(inString); 
    if (inString.equals("hello") == true) { // -this not working...
      exit();
    } 
  } else {
    background(0,25,59);
  }
}

and server:

import processing.net.*;

Server s; 
Client c;
String input;
int data[];

void setup() { 
  size(450, 255);
  background(204);
  s = new Server(this, 12345);
} 

void draw() { 
  if (mousePressed == true) {
    s.write("hello\n");
  }
}

Answers

Sign In or Register to comment.