public class Server
extends Object
implements Runnable
Modifier and Type | Field and Description |
---|---|
int |
clientCount
Number of clients currently connected.
|
Client[] |
clients
Array of client objects, useful length is determined by clientCount.
|
Constructor and Description |
---|
Server(PApplet parent,
int port) |
Server(PApplet parent,
int port,
String host) |
Modifier and Type | Method and Description |
---|---|
boolean |
active()
( begin auto-generated from Server_active.xml )
Returns true if this server is still active and hasn't run
into any trouble.
|
Client |
available()
( begin auto-generated from Server_available.xml )
Returns the next client in line with a new message.
|
void |
disconnect(Client client)
( begin auto-generated from Server_disconnect.xml )
Disconnect a particular client.
|
void |
dispose()
Disconnect all clients and stop the server: internal use only.
|
static String |
ip() |
void |
run() |
void |
stop()
( begin auto-generated from Server_stop.xml )
Disconnects all clients and stops the server.
|
void |
write(byte[] data) |
void |
write(int data)
( begin auto-generated from Server_write.xml )
Writes a value to all the connected clients.
|
void |
write(String data) |
public int clientCount
public Client[] clients
public Server(PApplet parent, int port)
parent
- typically use "this"port
- port used to transfer datapublic Server(PApplet parent, int port, String host)
host
- when multiple NICs are in use, the ip (or name) to bind frompublic void disconnect(Client client)
client
- the client to disconnectpublic boolean active()
public static String ip()
public Client available()
public void stop()
public void dispose()
public void run()
run
in interface Runnable
public void write(int data)
data
- data to writepublic void write(byte[] data)
public void write(String data)