mirror of
https://github.com/processing/processing4.git
synced 2026-01-29 03:11:08 +01:00
holy smokes what a mess
This commit is contained in:
@@ -51,7 +51,6 @@ public class Client implements Runnable {
|
||||
|
||||
Thread thread;
|
||||
Socket socket;
|
||||
String ip;
|
||||
int port;
|
||||
String host;
|
||||
|
||||
@@ -274,7 +273,10 @@ public class Client implements Runnable {
|
||||
* @brief Returns the IP address of the machine as a String
|
||||
*/
|
||||
public String ip() {
|
||||
return socket.getInetAddress().getHostAddress();
|
||||
if (socket != null){
|
||||
return socket.getInetAddress().getHostAddress();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -178,6 +178,15 @@ public class Server implements Runnable {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if this server is still active and hasn't run
|
||||
* into any trouble.
|
||||
*/
|
||||
public boolean active() {
|
||||
return thread != null;
|
||||
}
|
||||
|
||||
|
||||
static public String ip() {
|
||||
try {
|
||||
return InetAddress.getLocalHost().getHostAddress();
|
||||
@@ -310,8 +319,8 @@ public class Server implements Runnable {
|
||||
public void write(int data) { // will also cover char
|
||||
int index = 0;
|
||||
while (index < clientCount) {
|
||||
clients[index].write(data);
|
||||
if (clients[index].active()) {
|
||||
clients[index].write(data);
|
||||
index++;
|
||||
} else {
|
||||
removeIndex(index);
|
||||
@@ -323,8 +332,8 @@ public class Server implements Runnable {
|
||||
public void write(byte data[]) {
|
||||
int index = 0;
|
||||
while (index < clientCount) {
|
||||
clients[index].write(data);
|
||||
if (clients[index].active()) {
|
||||
clients[index].write(data);
|
||||
index++;
|
||||
} else {
|
||||
removeIndex(index);
|
||||
@@ -336,8 +345,8 @@ public class Server implements Runnable {
|
||||
public void write(String data) {
|
||||
int index = 0;
|
||||
while (index < clientCount) {
|
||||
clients[index].write(data);
|
||||
if (clients[index].active()) {
|
||||
clients[index].write(data);
|
||||
index++;
|
||||
} else {
|
||||
removeIndex(index);
|
||||
|
||||
@@ -135,6 +135,15 @@ public class Serial implements SerialPortEventListener {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return true if this port is still active and hasn't run
|
||||
* into any trouble.
|
||||
*/
|
||||
public boolean active() {
|
||||
return port.isOpened();
|
||||
}
|
||||
|
||||
|
||||
public void pre() {
|
||||
if (serialAvailableMethod != null && invokeSerialAvailable) {
|
||||
invokeSerialAvailable = false;
|
||||
|
||||
Reference in New Issue
Block a user