mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
Added EventMeta data, EventRegistry
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.toop;
|
||||
|
||||
import org.toop.eventbus.EventRegistry;
|
||||
import org.toop.eventbus.Events;
|
||||
import org.toop.eventbus.GlobalEventBus;
|
||||
import org.toop.server.Server;
|
||||
@@ -7,6 +8,18 @@ import org.toop.server.Server;
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
GlobalEventBus.subscribeAndRegister(Events.ServerEvents.OnChangingServerBackend.class, e -> {
|
||||
System.out.println("Server backend has changed to -> " + e.backend());
|
||||
});
|
||||
|
||||
GlobalEventBus.subscribeAndRegister(Events.ServerEvents.OnChangingServerIp.class, e -> {
|
||||
System.out.println("Server ip has changed to -> " + e.ip());
|
||||
});
|
||||
|
||||
GlobalEventBus.subscribeAndRegister(Events.ServerEvents.OnChangingServerPort.class, e -> {
|
||||
System.out.println("Server port has changed to -> " + e.port());
|
||||
});
|
||||
|
||||
Server server = new Server(Server.ServerBackend.LOCAL, "127.0.0.1", "5000");
|
||||
server.setBackend(Server.ServerBackend.REMOTE);
|
||||
|
||||
@@ -17,15 +30,17 @@ public class Main {
|
||||
else if (e.command() == Server.Command.HELP) {
|
||||
System.out.println("HELP command -> " + String.join(" ", e.args()));
|
||||
}
|
||||
});
|
||||
|
||||
GlobalEventBus.subscribeAndRegister(Events.ServerEvents.OnChangingServerBackend.class, e -> {
|
||||
System.out.println("Server backend has changed to -> " + e.backend());
|
||||
else {
|
||||
System.out.println(e.command().toString());
|
||||
}
|
||||
});
|
||||
|
||||
Server.Message msg = server.sendCommand(Server.Command.LOGIN, "move");
|
||||
server.sendCommand(Server.Command.HELP, "test", "test2");
|
||||
server.sendCommand(Server.Command.BYE);
|
||||
|
||||
GlobalEventBus.post(new Events.ServerEvents.changeServerIp("127.1.1.1"));
|
||||
GlobalEventBus.post(new Events.ServerEvents.changeServerPort("5003"));
|
||||
server.setBackend(Server.ServerBackend.REMOTE);
|
||||
|
||||
System.out.println(msg);
|
||||
|
||||
Reference in New Issue
Block a user