Fixed startup and store in db.
This commit is contained in:
parent
73f201bdac
commit
b93f1d7ef1
|
@ -21,5 +21,10 @@
|
|||
<artifactId>no2all-wire-ojw</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
|
@ -60,7 +60,7 @@ public class NoStrRtsServer implements No2AllReactTypeScript {
|
|||
NoStrFirePipe pipeReader = NoStr.FACTORY.pipeReaderRelay(reason -> {
|
||||
react.fire(socketSlot, No2AllActServerSocketClose.ofRefuse(reason));
|
||||
}, message -> {
|
||||
react.fire(serverSlot, message);
|
||||
react.fire(socketSlot, message);
|
||||
});
|
||||
react.registrate(socketSlot, No2AllArtServerSocketOnMessage.class, v -> {
|
||||
pipeReader.onFire(v.getData().getMessage());
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package love.distributedrebirth.no2all.react.nostr.server.relay;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import love.distributedrebirth.no2all.nostr.model.event.NoStrEvent;
|
||||
import love.distributedrebirth.no2all.nostr.model.event.NoStrEventSignature;
|
||||
import love.distributedrebirth.no2all.nostr.model.message.NoStrMsgToClientOk;
|
||||
|
@ -18,11 +20,13 @@ import love.distributedrebirth.no2all.react.wire.server.No2AllRtsServer;
|
|||
public class NoStrRtsServerRelay implements No2AllReactTypeScript {
|
||||
|
||||
public static final No2AllReactSlot API = No2AllReactSlot.ofClass(NoStrRtsServerRelay.class);
|
||||
private static final Logger logger = Logger.getLogger(NoStrRtsServerRelay.class.getName());
|
||||
|
||||
@Override
|
||||
public void onEvent(No2AllReactSlotSignal<No2AllReactSlotLoad> signal) {
|
||||
No2AllReact react = signal.getReact();
|
||||
react.claim(API);
|
||||
react.claimOut(API, NoStrArtServerRelayStoreEvent.class);
|
||||
react.requireSlot(API, NoStrRtsServer.API);
|
||||
react.registrate(No2AllRtsServer.API, No2AllArtServer.class, artServer -> {
|
||||
No2AllReactSlot serverSlot = artServer.getData().getSlot();
|
||||
|
@ -50,7 +54,7 @@ public class NoStrRtsServerRelay implements No2AllReactTypeScript {
|
|||
eventReason = NoStrImplMessageOkReason.INVALID;
|
||||
}
|
||||
|
||||
System.out.println("Validate event: " + eventSaved + " eventId: " + event.getId());
|
||||
logger.fine("Validate event: " + eventSaved + " eventId: " + event.getId());
|
||||
|
||||
|
||||
if (eventSaved) {
|
||||
|
|
|
@ -10,7 +10,7 @@ import love.distributedrebirth.no2all.nostr.fire.NoStrFireWaterBoiler;
|
|||
import love.distributedrebirth.no2all.nostr.model.NoStrIdentity;
|
||||
import love.distributedrebirth.no2all.nostr.model.NoStrIdentityPrivateKey;
|
||||
import love.distributedrebirth.no2all.nostr.model.event.NoStrEvent;
|
||||
import love.distributedrebirth.no2all.nostr.model.message.NoStrMsgToRelayClose;
|
||||
import love.distributedrebirth.no2all.nostr.model.message.NoStrMsgToRelayEvent;
|
||||
import love.distributedrebirth.no2all.nostr.nip.NoStrImplEventKind;
|
||||
import love.distributedrebirth.no2all.react.No2AllReactSlot;
|
||||
import love.distributedrebirth.no2all.react.warp.No2AllReactWarpCore;
|
||||
|
@ -21,18 +21,17 @@ import love.distributedrebirth.no2all.react.wire.client.No2AllActClientConnect;
|
|||
import love.distributedrebirth.no2all.react.wire.client.No2AllArtClient;
|
||||
import love.distributedrebirth.no2all.react.wire.client.No2AllArtClientOnClose;
|
||||
import love.distributedrebirth.no2all.react.wire.client.No2AllArtClientOnError;
|
||||
import love.distributedrebirth.no2all.react.wire.client.No2AllArtClientOnMessage;
|
||||
import love.distributedrebirth.no2all.react.wire.client.No2AllArtClientOnOpen;
|
||||
import love.distributedrebirth.no2all.react.wire.client.No2AllArtClientOnStart;
|
||||
import love.distributedrebirth.no2all.react.wire.client.No2AllRtsClient;
|
||||
import love.distributedrebirth.no2all.wire.ojw.OjwWireClientEndpoint;
|
||||
|
||||
public class NoStrClientTest {
|
||||
|
||||
private final static NoStrIdentity SENDER = new NoStrIdentity(NoStrIdentityPrivateKey.ofRandom());
|
||||
// private final static Map<String, String> RELAYS = Map.of("brb", "brb.io",
|
||||
// "damus", "relay.damus.io", "ZBD", "nostr.zebedee.cloud", "taxi",
|
||||
// "relay.taxi", "vision", "relay.nostr.vision");
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ExecutorService executor = Executors.newFixedThreadPool(10);
|
||||
NoStrIdentity nid = new NoStrIdentity(NoStrIdentityPrivateKey.ofRandom());
|
||||
No2AllReactWarpCore react = new No2AllReactWarpCore();
|
||||
react.load(new No2AllRtsWarpSpeedMonitor());
|
||||
react.load(new No2AllRtsClient());
|
||||
|
@ -40,35 +39,55 @@ public class NoStrClientTest {
|
|||
|
||||
react.registrate(No2AllRtsClient.API, No2AllArtClient.class, v -> {
|
||||
No2AllReactSlot clientSlot = v.getData().getSlot();
|
||||
System.out.println("NoStrClient connect");
|
||||
System.out.println("NoStrClient created: " + clientSlot.getSlotPath());
|
||||
react.registrate(clientSlot, No2AllArtClientOnError.class, x -> {
|
||||
System.out.println("NoStrClient socket error: " + x.getData().getError().getMessage());
|
||||
});
|
||||
react.registrate(clientSlot, No2AllArtClientOnClose.class, x -> {
|
||||
System.out.println("NoStrClient socket close");
|
||||
System.out.println("NoStrClient socket close: " + x.getData().getCode() + " " + x.getData().getReason());
|
||||
});
|
||||
react.registrate(clientSlot, No2AllArtClientOnOpen.class, x -> {
|
||||
System.out.println("NoStrClient socket open");
|
||||
react.fire(clientSlot, new NoStrMsgToRelayClose("give-me-error"));
|
||||
|
||||
executor.submit(() -> {
|
||||
try {
|
||||
for (int i = 0; i < 10; i++) {
|
||||
NoStrFireWaterBoiler userBoiler = NoStr.FACTORY.boiler(nid);
|
||||
NoStrEvent event = userBoiler.smoker()
|
||||
.tagSubject("Reply to all")
|
||||
.tagR("")
|
||||
.burn()
|
||||
.water(NoStrImplEventKind.TEXT_NOTE, "Hello world:"+i);
|
||||
|
||||
System.out.println("send msg");
|
||||
NoStrMsgToRelayEvent msg = new NoStrMsgToRelayEvent(event);
|
||||
react.fire(clientSlot, msg);
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
react.registrate(clientSlot, No2AllArtClientOnMessage.class, y -> {
|
||||
System.out.println("NoStrClient got msg1: " + y.getData().getMessage());
|
||||
});
|
||||
// Todo "OnStart" is not working...
|
||||
react.registrate(clientSlot, No2AllArtClientOnStart.class, x -> {
|
||||
System.out.println("NoStrClient socket start");
|
||||
});
|
||||
react.fire(clientSlot, new No2AllActClientConnect());
|
||||
});
|
||||
|
||||
OjwWireClientEndpoint clientEndpoint = new OjwWireClientEndpoint(new URI("ws://localhost:8080"));
|
||||
|
||||
OjwWireClientEndpoint clientEndpoint = new OjwWireClientEndpoint(new URI("ws://localhost:8080/event"));
|
||||
System.out.println("NoStrClient start");
|
||||
react.fire(No2AllRtsClient.API, new No2AllActClient(clientEndpoint));
|
||||
|
||||
OjwWireClientEndpoint clientEndpoint2 = new OjwWireClientEndpoint(new URI("ws://localhost:8080"));
|
||||
System.out.println("NoStrClient start2");
|
||||
react.fire(No2AllRtsClient.API, new No2AllActClient(clientEndpoint2));
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
react.fire(No2AllRtsClient.API, SENDER);
|
||||
Thread.sleep(100);
|
||||
}
|
||||
|
||||
Thread.sleep(500);
|
||||
|
||||
|
||||
Thread.sleep(30000);
|
||||
|
||||
executor.shutdown();
|
||||
executor.awaitTermination(60, TimeUnit.SECONDS);
|
||||
Thread exitTimer = new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
|
@ -82,29 +101,4 @@ public class NoStrClientTest {
|
|||
});
|
||||
exitTimer.start();
|
||||
}
|
||||
|
||||
public static void main2(String[] args) throws Exception {
|
||||
|
||||
|
||||
|
||||
ExecutorService executor = Executors.newFixedThreadPool(10);
|
||||
executor.submit(() -> {
|
||||
try {
|
||||
NoStrFireWaterBoiler userBoiler = NoStr.FACTORY.boiler(SENDER);
|
||||
NoStrEvent event = userBoiler.smoker()
|
||||
.tagSubject("Reply to all")
|
||||
.tagR("")
|
||||
.burn()
|
||||
.water(NoStrImplEventKind.TEXT_NOTE, "Hello world");
|
||||
|
||||
System.out.println(event);
|
||||
// GenericMessage message = new EventMessage(event);
|
||||
// CLIENT.send(message);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
executor.shutdown();
|
||||
executor.awaitTermination(60, TimeUnit.SECONDS);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package love.distributedrebirth.no2all.react.wire.server;
|
||||
|
||||
import love.distributedrebirth.no2all.react.No2AllReactSlotLoad;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import love.distributedrebirth.no2all.react.No2AllReact;
|
||||
import love.distributedrebirth.no2all.react.No2AllReactSlot;
|
||||
import love.distributedrebirth.no2all.react.No2AllReactSlotSignal;
|
||||
|
@ -9,6 +12,7 @@ import love.distributedrebirth.no2all.react.No2AllReactTypeScript;
|
|||
public class No2AllRtsServerLog implements No2AllReactTypeScript {
|
||||
|
||||
public static final No2AllReactSlot API = No2AllReactSlot.ofClass(No2AllRtsServerLog.class);
|
||||
private static final Logger logger = Logger.getLogger(No2AllRtsServerLog.class.getName());
|
||||
|
||||
@Override
|
||||
public void onEvent(No2AllReactSlotSignal<No2AllReactSlotLoad> signal) {
|
||||
|
@ -17,16 +21,16 @@ public class No2AllRtsServerLog implements No2AllReactTypeScript {
|
|||
react.registrate(No2AllRtsServer.API, No2AllArtServer.class, artServer -> {
|
||||
No2AllReactSlot serverSlot = artServer.getData().getSlot();
|
||||
react.registrate(serverSlot, No2AllActServerBroadcastMessage.class, v -> {
|
||||
System.out.println("No2AllRtsServerLog.broadcastMessage: " + v.getData().getMessage());
|
||||
logger.info("broadcastMessage: " + v.getData().getMessage());
|
||||
});
|
||||
react.registrate(serverSlot, No2AllArtServerSocket.class, v -> {
|
||||
No2AllReactSlot socketSlot = v.getData().getSlot();
|
||||
String wireId = socketSlot.getSlotSlug();
|
||||
react.registrate(socketSlot, No2AllArtServerSocketOnMessage.class, z -> {
|
||||
System.out.println("No2AllRtsServerLog."+wireId+".socketOnMessage: " + z.getData().getMessage());
|
||||
logger.info(wireId+".socketOnMessage: " + z.getData().getMessage());
|
||||
});
|
||||
react.registrate(socketSlot, No2AllActServerSocketSendMessage.class, z -> {
|
||||
System.out.println("No2AllRtsServerLog."+wireId+".socketSendMessage: " + z.getData().getMessage());
|
||||
logger.info(wireId+".socketSendMessage: " + z.getData().getMessage());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -75,10 +75,12 @@ public class No2AllReactWarpCore implements No2AllReact {
|
|||
try {
|
||||
toWarpFuel(slot).fire(event, slot);
|
||||
|
||||
List<BacklogEvent> backlog2 = new ArrayList<>(backlog);
|
||||
backlog.clear();
|
||||
for (BacklogEvent next : backlog2) {
|
||||
toWarpFuel(next.slot).fire(next.event, next.slot);
|
||||
while (!backlog.isEmpty()) {
|
||||
List<BacklogEvent> backlog2 = new ArrayList<>(backlog);
|
||||
backlog.clear();
|
||||
for (BacklogEvent next : backlog2) {
|
||||
toWarpFuel(next.slot).fire(next.event, next.slot);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
currentEvent = null;
|
||||
|
|
|
@ -13,6 +13,7 @@ public final class JreWireClientHandler implements WebSocket.Listener {
|
|||
|
||||
protected JreWireClientHandler(WireClientHandler handler) {
|
||||
this.handler = handler;
|
||||
this.handler.onStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -11,8 +11,9 @@ public class OjwWireClient implements WireClient {
|
|||
|
||||
private final OjwWireClientHandler handler;
|
||||
|
||||
protected OjwWireClient(URI uri, Map<String, String> headers, int timeoutMs, WireClientHandler handler) {
|
||||
this.handler = new OjwWireClientHandler(uri, headers, timeoutMs, handler);
|
||||
protected OjwWireClient(URI uri, Map<String, String> headers, int timeoutMs, WireClientHandler wireHandler) {
|
||||
this.handler = new OjwWireClientHandler(uri, headers, timeoutMs, wireHandler);
|
||||
wireHandler.onStart();
|
||||
}
|
||||
|
||||
public OjwWireClientHandler getHandler() {
|
||||
|
|
|
@ -25,5 +25,6 @@
|
|||
|
||||
<!-- Package limits. -->
|
||||
<logger level="INFO" name="org.eclipse.jetty"/>
|
||||
<logger level="INFO" name="jakarta.json.spi"/>
|
||||
|
||||
</configuration>
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
<groupId>${project.groupId}</groupId>
|
||||
<artifactId>no2all-wire-jetty</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.parsson</groupId>
|
||||
<artifactId>parsson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package love.distributedrebirth.no2all.zerofungus;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import jakarta.json.Json;
|
||||
import jakarta.json.JsonWriter;
|
||||
import love.distributedrebirth.no2all.nostr.model.event.NoStrEvent;
|
||||
import love.distributedrebirth.no2all.react.No2AllReact;
|
||||
import love.distributedrebirth.no2all.react.No2AllReactSlot;
|
||||
import love.distributedrebirth.no2all.react.No2AllReactSlotLoad;
|
||||
import love.distributedrebirth.no2all.react.No2AllReactSlotSignal;
|
||||
import love.distributedrebirth.no2all.react.No2AllReactTypeScript;
|
||||
import love.distributedrebirth.no2all.react.nostr.server.relay.NoStrArtServerRelayStoreEvent;
|
||||
import love.distributedrebirth.no2all.react.nostr.server.relay.NoStrRtsServerRelay;
|
||||
|
||||
public class ZFunRtsServer implements No2AllReactTypeScript {
|
||||
|
||||
public static final No2AllReactSlot API = No2AllReactSlot.ofClass(ZFunRtsServer.class);
|
||||
private static final Logger logger = Logger.getLogger(ZFunRtsServer.class.getName());
|
||||
|
||||
@Override
|
||||
public void onEvent(No2AllReactSlotSignal<No2AllReactSlotLoad> signal) {
|
||||
No2AllReact react = signal.getReact();
|
||||
react.claim(API);
|
||||
|
||||
DataSource ds = react.service(DataSource.class);
|
||||
react.registrate(NoStrRtsServerRelay.API, NoStrArtServerRelayStoreEvent.class, storeEvent -> {
|
||||
logger.info("Store event: " + storeEvent.getData().getEvent().getId().getHexDipavali());
|
||||
NoStrEvent event = storeEvent.getData().getEvent();
|
||||
StringWriter jsonStr = new StringWriter();
|
||||
try (JsonWriter writer = Json.createWriter(jsonStr)) {
|
||||
writer.write(event.toBible());
|
||||
}
|
||||
try (Connection conn = ds.getConnection()) {
|
||||
String sql = "INSERT INTO \"ᔆʸᔆᐪᓫᔿ\".\"ᔆᐪᣔᒼᒽᑉ\" (\"ᑊᑊᐣ\",\"ᣖᓑᒃᒽᑉᓫᔾ\",\"ᒼᣗᓫᣔᐪᓫᐝᒄᐪ\",\"ᑊᑉᑊᣕᒄ\",\"ᒄᓫᒻᐪᣔᕐ\",\"ᓫᕁᣖᑊᣗᓫᐝᒄᐪ\",\"ᣗᣔᒡᒢ\") VALUES (?,?,?,?,?,?,?)";
|
||||
PreparedStatement prep = conn.prepareStatement(sql);
|
||||
prep.setString(1, event.getId().getHex());
|
||||
prep.setString(2, event.getPayload().getPublicKey().getHex());
|
||||
prep.setDate(3, new java.sql.Date(event.getPayload().getCreatedAt().toEpochMilli()));
|
||||
prep.setInt(4, event.getPayload().getKind().getNumber());
|
||||
prep.setString(5, null); // del tag
|
||||
prep.setString(6, null); // exp date
|
||||
prep.setString(7, jsonStr.toString());
|
||||
prep.executeUpdate();
|
||||
} catch (SQLException e) {
|
||||
logger.warning(e.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
|
@ -7,17 +7,14 @@ import love.distributedrebirth.no2all.react.No2AllReactSlotLoad;
|
|||
import love.distributedrebirth.no2all.react.No2AllReactSlotSignal;
|
||||
import love.distributedrebirth.no2all.react.No2AllReactTypeScript;
|
||||
|
||||
public class ZFunServer implements No2AllReactTypeScript {
|
||||
public class ZFunRtsServerBooted implements No2AllReactTypeScript {
|
||||
|
||||
public static final No2AllReactSlot API = No2AllReactSlot.ofClass(ZFunServer.class);
|
||||
private static final Logger logger = Logger.getLogger(ZFunServer.class.getName());
|
||||
public static final No2AllReactSlot API = No2AllReactSlot.ofClass(ZFunRtsServerBooted.class);
|
||||
private static final Logger logger = Logger.getLogger(ZFunRtsServerBooted.class.getName());
|
||||
|
||||
@Override
|
||||
public void onEvent(No2AllReactSlotSignal<No2AllReactSlotLoad> signal) {
|
||||
signal.getReact().claim(API);
|
||||
|
||||
// TODO: reg and refire events
|
||||
|
||||
logger.info("╔═╗┌─┐┬─┐┌─┐ .╔═╗┬ ┬┌┐┌╔═╗┬ ┬┌─┐");
|
||||
logger.info("╔═╝├┤ ├┬┘│ │ . ╠╣ │ ││││║ ╦│ │└─┐");
|
||||
logger.info("╚═╝└─┘┴└─└─┘. ╚ └─┘┘└┘╚═╝└─┘└─┘");
|
|
@ -1,7 +1,12 @@
|
|||
package love.distributedrebirth.no2all.zerofungus;
|
||||
|
||||
import love.distributedrebirth.no2all.react.nostr.client.NoStrRtsClient;
|
||||
import love.distributedrebirth.no2all.react.nostr.server.NoStrRtsServer;
|
||||
import love.distributedrebirth.no2all.react.nostr.server.relay.NoStrRtsServerRelay;
|
||||
import love.distributedrebirth.no2all.react.nostr.server.relay.NoStrRtsServerRelaySubs;
|
||||
import love.distributedrebirth.no2all.react.warp.No2AllReactWarpCore;
|
||||
import love.distributedrebirth.no2all.react.warp.No2AllRtsWarpSpeedMonitor;
|
||||
import love.distributedrebirth.no2all.react.wire.client.No2AllRtsClient;
|
||||
import love.distributedrebirth.no2all.react.wire.server.No2AllRtsServer;
|
||||
import love.distributedrebirth.no2all.react.wire.server.No2AllRtsServerLog;
|
||||
import love.distributedrebirth.no2all.zerofungus.service.ZFunRtsConfigJetty;
|
||||
|
@ -23,14 +28,29 @@ public enum ZeroFungus /*implements BãßBȍőnAbacusInstanceMBeanʸᴰ<ZeroFung
|
|||
}
|
||||
|
||||
public void start() {
|
||||
// setup logger + warp monitor
|
||||
foei.load(new ZFunRtsConfigLogger());
|
||||
foei.load(new No2AllRtsWarpSpeedMonitor());
|
||||
|
||||
// add websocket wire support + log
|
||||
foei.load(new No2AllRtsClient());
|
||||
foei.load(new No2AllRtsServer());
|
||||
foei.load(new No2AllRtsServerLog());
|
||||
foei.load(ZFunRtsConfigJetty.INSTANCE);
|
||||
foei.load(new ZFunRtsInitJdbc(foei));
|
||||
foei.load(new ZFunServer());
|
||||
|
||||
// add nostr support
|
||||
foei.load(new NoStrRtsClient());
|
||||
foei.load(new NoStrRtsServer());
|
||||
foei.load(new NoStrRtsServerRelay());
|
||||
foei.load(new NoStrRtsServerRelaySubs());
|
||||
|
||||
// config zero fungus servers and clients
|
||||
foei.load(new ZFunRtsInitJdbc(foei));
|
||||
foei.load(new ZFunRtsServer());
|
||||
//foei.load(new ZFunRtsClientReplay());
|
||||
|
||||
// start jetty
|
||||
foei.load(ZFunRtsConfigJetty.INSTANCE);
|
||||
foei.load(new ZFunRtsServerBooted());
|
||||
ZFunRtsConfigJetty.INSTANCE.join();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,10 +27,6 @@ import love.distributedrebirth.no2all.react.No2AllReactSlotLoad;
|
|||
import love.distributedrebirth.no2all.react.No2AllReactSlotSignal;
|
||||
import love.distributedrebirth.no2all.react.No2AllReactTypeScript;
|
||||
import love.distributedrebirth.no2all.react.wire.server.No2AllActServer;
|
||||
import love.distributedrebirth.no2all.react.wire.server.No2AllActServerSocketSendMessage;
|
||||
import love.distributedrebirth.no2all.react.wire.server.No2AllArtServer;
|
||||
import love.distributedrebirth.no2all.react.wire.server.No2AllArtServerSocket;
|
||||
import love.distributedrebirth.no2all.react.wire.server.No2AllArtServerSocketOnMessage;
|
||||
import love.distributedrebirth.no2all.react.wire.server.No2AllRtsServer;
|
||||
import love.distributedrebirth.no2all.wire.jetty.JettyWireServerEndpoint;
|
||||
import love.distributedrebirth.no2all.zerofungus.web.RedirectServlet;
|
||||
|
@ -93,29 +89,17 @@ public enum ZFunRtsConfigJetty implements No2AllReactTypeScript {
|
|||
|
||||
No2AllReact react = signal.getReact();
|
||||
server.addEventListener(new Listener() {
|
||||
|
||||
@Override
|
||||
public void lifeCycleStarted(LifeCycle event) {
|
||||
// auto reply
|
||||
react.registrate(No2AllRtsServer.API, No2AllArtServer.class, artServer -> {
|
||||
No2AllReactSlot serverSlot = artServer.getData().getSlot();
|
||||
react.registrate(serverSlot, No2AllArtServerSocket.class, artSocket -> {
|
||||
No2AllReactSlot socketSlot = artSocket.getData().getSlot();
|
||||
react.registrate(socketSlot, No2AllArtServerSocketOnMessage.class, artMsg -> {
|
||||
react.fire(socketSlot,
|
||||
new No2AllActServerSocketSendMessage("RE: " + artMsg.getData().getMessage()));
|
||||
});
|
||||
});
|
||||
});
|
||||
react.fire(No2AllRtsServer.API, new No2AllActServer(endpoint1));
|
||||
react.fire(No2AllRtsServer.API, new No2AllActServer(endpoint2));
|
||||
react.fire(No2AllRtsServer.API, new No2AllActServer(endpoint3));
|
||||
}
|
||||
});
|
||||
try {
|
||||
logger.info("start");
|
||||
logger.info("start jetty");
|
||||
server.start();
|
||||
logger.info("start done");
|
||||
logger.info("jetty started");
|
||||
} catch (Exception e) {
|
||||
throw new IllegalStateException(e);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package love.distributedrebirth.no2all.zerofungus.service;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
@ -20,32 +18,26 @@ public class ZFunRtsConfigLogger implements No2AllReactTypeScript {
|
|||
|
||||
@Override
|
||||
public void onEvent(No2AllReactSlotSignal<No2AllReactSlotLoad> signal) {
|
||||
if (System.getProperty("logback.configurationFile") != null) {
|
||||
File logConfig = null;
|
||||
if (System.getProperty("logback.configurationFile") == null) {
|
||||
String logConfig = null;
|
||||
if (System.getProperty("java.class.path").contains("classes")) {
|
||||
logConfig = new File("conf/logback-server-console.xml");
|
||||
logConfig = "conf/logback-server-console.xml";
|
||||
} else {
|
||||
logConfig = new File("conf/logback-server.xml");
|
||||
}
|
||||
try {
|
||||
System.setProperty("logback.configurationFile", logConfig.toURI().toURL().toExternalForm());
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
logConfig = "conf/logback-server.xml";
|
||||
}
|
||||
System.setProperty("logback.configurationFile", logConfig);
|
||||
}
|
||||
System.setProperty("logback.statusListenerClass",NopStatusListener.class.getName());
|
||||
|
||||
System.setProperty("logback.configurationFile","conf/logback-server-console.xml");
|
||||
org.slf4j.Logger logger2 = LoggerFactory.getLogger("MyTest");
|
||||
logger2.debug("Hello world.");
|
||||
if (System.getProperty("logback.statusListenerClass") == null) {
|
||||
System.setProperty("logback.statusListenerClass",NopStatusListener.class.getName());
|
||||
}
|
||||
org.slf4j.Logger logger2 = LoggerFactory.getLogger(ZFunRtsConfigLogger.class);
|
||||
logger2.info("Logging configured.");
|
||||
|
||||
SLF4JBridgeHandler.removeHandlersForRootLogger();
|
||||
SLF4JBridgeHandler.install();
|
||||
logger.info("Logging configured");
|
||||
logger.info(" ╦┌─┐╔╦╗╔╦╗┬ ┬ ╔═╗┌─┐╦ ╦╔═╗┬─┐┌┬┐");
|
||||
logger.info(" ║├┤ ║ ║ └┬┘ ╠═╝│ │║║║║╣ ├┬┘ ││");
|
||||
logger.info("╚╝└─┘ ╩ ╩ ┴ ╩ └─┘╚╩╝╚═╝┴└──┴┘");
|
||||
|
||||
logger.info(" ╦┬ ┬╦ ╦═╗┌─┐╦ ╦┬╦═╗┌─┐╔╦╗");
|
||||
logger.info(" ║│ │║ ╠╦╝├┤ ║║║│╠╦╝├┤ ║║");
|
||||
logger.info("╚╝└─┘╩═╝ ╩╚═└─┘╚╩╝┴╩╚═└─┘═╩╝");
|
||||
//https://patorjk.com/software/taag
|
||||
// Calvin S
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue