vnoření mapObject zpet do map
parent
79aa1678b2
commit
0c50656f13
|
|
@ -0,0 +1 @@
|
||||||
|
*.log
|
||||||
|
|
@ -50,10 +50,12 @@ public class Message implements Serializable {
|
||||||
// C->S: klient odesila upravu serveru
|
// C->S: klient odesila upravu serveru
|
||||||
public static final int SERVER_CONFIG = 13;
|
public static final int SERVER_CONFIG = 13;
|
||||||
|
|
||||||
//S->C: server odesila seznam objektu
|
// C->S: klient posila požadavek na restart serveru
|
||||||
public static final int OBJECT_LIST = 14;
|
public static final int RESTART = 15;
|
||||||
|
|
||||||
|
|
||||||
|
// C->S: klient se dotazuje na uptime server
|
||||||
|
// S->C: server odesila uptim serveru
|
||||||
|
public static final int UPTIME = 16;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,23 +4,21 @@ import jnet.lib.Status;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @author cucky
|
|
||||||
*/
|
|
||||||
public class Map implements Serializable {
|
public class Map implements Serializable {
|
||||||
|
|
||||||
private int id;
|
private int id;
|
||||||
private String name;
|
private String name;
|
||||||
private boolean lock;
|
private boolean lock;
|
||||||
//private ArrayList<MapObject> objects;
|
private ArrayList<MapObject> objects;
|
||||||
private int status;
|
private int status;
|
||||||
|
|
||||||
public Map(int id, String name, boolean lock) {
|
public Map(int id, String name, boolean lock, ArrayList<MapObject> objects) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.lock = lock;
|
this.lock = lock;
|
||||||
this.status = Status.NA;
|
this.status = Status.NA;
|
||||||
|
this.objects = objects;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map(String name) {
|
public Map(String name) {
|
||||||
|
|
@ -28,8 +26,6 @@ public class Map implements Serializable {
|
||||||
this.lock = false;
|
this.lock = false;
|
||||||
this.status = Status.NA;
|
this.status = Status.NA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
|
|
@ -55,5 +51,36 @@ public class Map implements Serializable {
|
||||||
this.lock = lock;
|
this.lock = lock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<MapObject> getObjects() {
|
||||||
|
return objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setObjects(ArrayList<MapObject> objects) {
|
||||||
|
this.objects = objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStatus() {
|
||||||
|
if (getObjects().isEmpty()) {
|
||||||
|
return Status.NA;
|
||||||
|
}
|
||||||
|
|
||||||
|
int status = Status.OK;
|
||||||
|
|
||||||
|
for (MapObject object : getObjects()) {
|
||||||
|
int objectStatus = object.getStatus();
|
||||||
|
|
||||||
|
if (objectStatus == Status.OFFLINE) {
|
||||||
|
return Status.OFFLINE; // Okamžitě vrátíme OFFLINE
|
||||||
|
} else if (objectStatus == Status.WARNING) {
|
||||||
|
status = Status.WARNING; // Možný downgrade na WARNING
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(int status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,18 +4,28 @@ import java.io.Serializable;
|
||||||
|
|
||||||
public class ServerConfig implements Serializable {
|
public class ServerConfig implements Serializable {
|
||||||
|
|
||||||
|
private int pingRepeat;
|
||||||
private int pingAttempt;
|
private int pingAttempt;
|
||||||
private int pingTimeout;
|
private int pingTimeout;
|
||||||
private int instabilityAttempt;
|
private int instabilityAttempt;
|
||||||
private int instabilityLimit;
|
private int instabilityLimit;
|
||||||
|
|
||||||
public ServerConfig(int pingAttempt, int pingTimeout, int instabilityAttempt, int instabilityLimit) {
|
public ServerConfig(int pingRepeat, int pingAttempt, int pingTimeout, int instabilityAttempt, int instabilityLimit) {
|
||||||
|
this.pingRepeat = pingRepeat;
|
||||||
this.pingAttempt = pingAttempt;
|
this.pingAttempt = pingAttempt;
|
||||||
this.pingTimeout = pingTimeout;
|
this.pingTimeout = pingTimeout;
|
||||||
this.instabilityAttempt = instabilityAttempt;
|
this.instabilityAttempt = instabilityAttempt;
|
||||||
this.instabilityLimit = instabilityLimit;
|
this.instabilityLimit = instabilityLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPingRepeat() {
|
||||||
|
return pingRepeat;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPingRepeat(int pingRepeat) {
|
||||||
|
this.pingRepeat = pingRepeat;
|
||||||
|
}
|
||||||
|
|
||||||
public int getPingAttempt() {
|
public int getPingAttempt() {
|
||||||
return pingAttempt;
|
return pingAttempt;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue