clientEvent called continuesly
in
Core Library Questions
•
2 years ago
Hi group,
I have a set of scripts that communicate via the network. Which works with one small problem. The clientEvent routine is called even if no data has been sent. It is my understanding that it is only to be called when there is data to read?
I'm sure it is the way I have it written?
Any ideas??
William Estrada
Mt Umunhum, CA, USA
HTTP://64.124.13.3 ( Mt-Umunhum-Wireless.net )
Skype: MrUmunhum
I have a set of scripts that communicate via the network. Which works with one small problem. The clientEvent routine is called even if no data has been sent. It is my understanding that it is only to be called when there is data to read?
I'm sure it is the way I have it written?
- import processing.net.*;
Client C;
String data;
int[] P = new int[2];
void setup() {
size(500,500);
smooth();
background( 255 );
C = new Client( this, "127.0.0.1", 5204 );
P[1] = 45; }
void draw() {
fill( P[1] % 255, 0, 0 );
translate( 250,250);
rotate( P[1] % 360 );
rect( 45, 45, 55, 55 ); }
void clientEvent( Client C ) {
println("Event");
int Yes;
while( ( Yes = C.available() ) != 0 ) {
println("read: " + Yes);
data = C.readStringUntil( '\n' );
P = int( splitTokens( data, " \n" ) );
}
}
- import processing.net.*;
Server S; float Old; float Now;
void setup() {
S = new Server( this, 5204); }
void draw() {
Now = millis();
int Time = int( ( Now - Old ) /100 );
int B = int( random( 0, 360 ) );
String Line = Time + " " + B + "\n";
if( true ) { S.write( Line ); }
else { print(Line); }
delay(1000);
Old = Now;
}
- read: 6Event
Event
Event
Event
Event
Event
Event
Event
Event
Event
Event
Event
Event
Event
Event
Event
Event
Event
Event
Event
. . . .
William Estrada
Mt Umunhum, CA, USA
HTTP://64.124.13.3 ( Mt-Umunhum-Wireless.net )
Skype: MrUmunhum
1