Hi! This is a little list of things that i found missing or wrong in the Net library reference:
In the method/event list:
There says "Client()" and shoud say "Client"
In the "Client.available()":
The description is not clear enough, is it the number of available bytes from the server? (i think so)
For the "Server.available()" method here is an example:
Code:
import processing.net.*;
Server myServer;
int port = 10002;
void setup() {
myServer = new Server(this, port);
}
void draw() {
Client remoteClient = myServer.available();
if(remoteClient != null) {
String message = remoteClient.readStringUntil(RETURN);
if (message != null) {
myServer.write("The client " + remoteClient.ip() + " wrote " + message);
}
}
}
For the "stop()" method, here is an example:
Code:
import processing.net.*;
Server myServer;
int port = 10002;
int counter;
void setup() {
myServer = new Server(this, port);
}
void draw() {
counter++;
if(counter < 1000) {
myServer.write(counter);
} else {
myServer.stop();
}
}
For the "disconnect()" method, here is an example:
Code:
import processing.net.*;
Server myServer;
int port = 10002;
void setup() {
myServer = new Server(this, port);
}
void draw() {
Client remoteClient = myServer.available();
if(remoteClient != null) {
int message = remoteClient.readStringUntil(RETURN);
if (message == 255) {
myServer.disconnect(remoteClient);
}
}
}