mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
moving examples to hang out with their libraries
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Chat Server
|
||||
* by Tom Igoe.
|
||||
*
|
||||
* Press the mouse to stop the server.
|
||||
*/
|
||||
|
||||
|
||||
import processing.net.*;
|
||||
|
||||
int port = 10002;
|
||||
boolean myServerRunning = true;
|
||||
int bgColor = 0;
|
||||
int direction = 1;
|
||||
int textLine = 60;
|
||||
|
||||
Server myServer;
|
||||
|
||||
void setup()
|
||||
{
|
||||
size(400, 400);
|
||||
textFont(createFont("SanSerif", 16));
|
||||
myServer = new Server(this, port); // Starts a myServer on port 10002
|
||||
background(0);
|
||||
}
|
||||
|
||||
void mousePressed()
|
||||
{
|
||||
// If the mouse clicked the myServer stops
|
||||
myServer.stop();
|
||||
myServerRunning = false;
|
||||
}
|
||||
|
||||
void draw()
|
||||
{
|
||||
if (myServerRunning == true)
|
||||
{
|
||||
text("server", 15, 45);
|
||||
Client thisClient = myServer.available();
|
||||
if (thisClient != null) {
|
||||
if (thisClient.available() > 0) {
|
||||
text("mesage from: " + thisClient.ip() + " : " + thisClient.readString(), 15, textLine);
|
||||
textLine = textLine + 35;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
text("server", 15, 45);
|
||||
text("stopped", 15, 65);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Reference in New Issue
Block a user