mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
Added events
This commit is contained in:
@@ -18,6 +18,26 @@ public class Events {
|
|||||||
*/
|
*/
|
||||||
public record OnChangingServerBackend(Server.ServerBackend backend) {}
|
public record OnChangingServerBackend(Server.ServerBackend backend) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers changing the server ip.
|
||||||
|
*/
|
||||||
|
public record changeServerIp(String ip) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers on changing the server ip.
|
||||||
|
*/
|
||||||
|
public record OnChangingServerIp(String ip) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers changing the server port.
|
||||||
|
*/
|
||||||
|
public record changeServerPort(String port) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Triggers on changing the server port.
|
||||||
|
*/
|
||||||
|
public record OnChangingServerPort(String port) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class Server {
|
|||||||
ip = set_ip;
|
ip = set_ip;
|
||||||
port = set_port;
|
port = set_port;
|
||||||
setBackend(set_backend);
|
setBackend(set_backend);
|
||||||
|
this.initEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBackend getBackend() {
|
public IBackend getBackend() {
|
||||||
@@ -79,6 +79,7 @@ public class Server {
|
|||||||
|
|
||||||
public void setIp(String ip) {
|
public void setIp(String ip) {
|
||||||
this.ip = ip;
|
this.ip = ip;
|
||||||
|
GlobalEventBus.post(new Events.ServerEvents.OnChangingServerIp(ip));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPort() {
|
public String getPort() {
|
||||||
@@ -87,6 +88,7 @@ public class Server {
|
|||||||
|
|
||||||
public void setPort(String port) {
|
public void setPort(String port) {
|
||||||
this.port = port;
|
this.port = port;
|
||||||
|
GlobalEventBus.post(new Events.ServerEvents.OnChangingServerPort(port));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Message sendCommandString(String sentence) {
|
private Message sendCommandString(String sentence) {
|
||||||
@@ -152,4 +154,9 @@ public class Server {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initEvents() {
|
||||||
|
GlobalEventBus.subscribeAndRegister(Events.ServerEvents.changeServerIp.class, e -> this.setIp(e.ip()));
|
||||||
|
GlobalEventBus.subscribeAndRegister(Events.ServerEvents.changeServerPort.class, e -> this.setPort(e.port()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user