Intial commit

This commit is contained in:
Willem Cazander 2023-09-24 12:41:43 +02:00
parent 7329fb8dea
commit 73f201bdac
268 changed files with 11220 additions and 5 deletions

20
no2all-react-wire/pom.xml Normal file
View file

@ -0,0 +1,20 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>love.distributedrebirth.no2all</groupId>
<artifactId>no2all</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>no2all-react-wire</artifactId>
<name>No2All-React-Wire</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>no2all-react</artifactId>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>no2all-wire</artifactId>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,16 @@
package love.distributedrebirth.no2all.react.wire.client;
import love.distributedrebirth.no2all.wire.WireClientEndpoint;
public final class No2AllActClient {
private final WireClientEndpoint endpoint;
public No2AllActClient(WireClientEndpoint endpoint) {
this.endpoint = endpoint;
}
public WireClientEndpoint getEndpoint() {
return endpoint;
}
}

View file

@ -0,0 +1,28 @@
package love.distributedrebirth.no2all.react.wire.client;
public final class No2AllActClientClose {
private final int code;
private final String message;
public No2AllActClientClose(int code, String message) {
this.code = code;
this.message = message;
}
public int getCode() {
return code;
}
public String getMessage() {
return message;
}
public static No2AllActClientClose ofNormal(String message) {
return new No2AllActClientClose(1000, message);
}
public static No2AllActClientClose ofRefuse(String message) {
return new No2AllActClientClose(1003, message);
}
}

View file

@ -0,0 +1,7 @@
package love.distributedrebirth.no2all.react.wire.client;
public final class No2AllActClientConnect {
public No2AllActClientConnect() {
}
}

View file

@ -0,0 +1,16 @@
package love.distributedrebirth.no2all.react.wire.client;
import java.nio.ByteBuffer;
public final class No2AllActClientSendBinary {
private final ByteBuffer message;
public No2AllActClientSendBinary(ByteBuffer message) {
this.message = message;
}
public ByteBuffer getMessage() {
return message;
}
}

View file

@ -0,0 +1,14 @@
package love.distributedrebirth.no2all.react.wire.client;
public final class No2AllActClientSendMessage {
private final String message;
public No2AllActClientSendMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}

View file

@ -0,0 +1,11 @@
package love.distributedrebirth.no2all.react.wire.client;
import love.distributedrebirth.no2all.react.No2AllReactSlot;
import love.distributedrebirth.no2all.react.warp.No2AllActAbstractSlot;
public final class No2AllArtClient extends No2AllActAbstractSlot {
protected No2AllArtClient(No2AllReactSlot slot) {
super(slot);
}
}

View file

@ -0,0 +1,16 @@
package love.distributedrebirth.no2all.react.wire.client;
import java.nio.ByteBuffer;
public final class No2AllArtClientOnBinary {
private final ByteBuffer message;
protected No2AllArtClientOnBinary(ByteBuffer message) {
this.message = message;
}
public ByteBuffer getMessage() {
return message;
}
}

View file

@ -0,0 +1,26 @@
package love.distributedrebirth.no2all.react.wire.client;
public final class No2AllArtClientOnClose {
private final int code;
private final String reason;
private final boolean remote;
protected No2AllArtClientOnClose(int code, String reason, boolean remote) {
this.code = code;
this.reason = reason;
this.remote = remote;
}
public int getCode() {
return code;
}
public String getReason() {
return reason;
}
public boolean isRemote() {
return remote;
}
}

View file

@ -0,0 +1,14 @@
package love.distributedrebirth.no2all.react.wire.client;
public final class No2AllArtClientOnError {
private final Throwable error;
protected No2AllArtClientOnError(Throwable error) {
this.error = error;
}
public Throwable getError() {
return error;
}
}

View file

@ -0,0 +1,14 @@
package love.distributedrebirth.no2all.react.wire.client;
public final class No2AllArtClientOnMessage {
private final String message;
protected No2AllArtClientOnMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}

View file

@ -0,0 +1,7 @@
package love.distributedrebirth.no2all.react.wire.client;
public final class No2AllArtClientOnOpen {
protected No2AllArtClientOnOpen() {
}
}

View file

@ -0,0 +1,11 @@
package love.distributedrebirth.no2all.react.wire.client;
import love.distributedrebirth.no2all.react.No2AllReactSlot;
import love.distributedrebirth.no2all.react.warp.No2AllActAbstractSlot;
public final class No2AllArtClientOnStart extends No2AllActAbstractSlot {
protected No2AllArtClientOnStart(No2AllReactSlot slot) {
super(slot);
}
}

View file

@ -0,0 +1,90 @@
package love.distributedrebirth.no2all.react.wire.client;
import java.nio.ByteBuffer;
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.wire.WireClient;
import love.distributedrebirth.no2all.wire.WireClientEndpoint;
import love.distributedrebirth.no2all.wire.WireClientHandler;
public class No2AllRtsClient implements No2AllReactTypeScript {
public static final No2AllReactSlot API = No2AllReactSlot.ofClass(No2AllRtsClient.class);
@Override
public void onEvent(No2AllReactSlotSignal<No2AllReactSlotLoad> signal) {
No2AllReact react = signal.getReact();
react.claim(API);
react.claimIn(API, No2AllActClient.class);
react.claimOut(API, No2AllArtClient.class);
react.registrate(API, No2AllActClient.class, actClient -> {
WireClientEndpoint clientEndpoint = actClient.getData().getEndpoint();
No2AllReactSlot clientSlot = No2AllReactSlot.of(API, "wireId=" + clientEndpoint.wireId());
WireClient client = clientEndpoint.wireClient(wireHandler(react, clientSlot));
react.claim(clientSlot);
react.claimIn(clientSlot, No2AllActClientConnect.class);
react.claimIn(clientSlot, No2AllActClientClose.class);
react.claimIn(clientSlot, No2AllActClientSendMessage.class);
react.claimIn(clientSlot, No2AllActClientSendBinary.class);
react.claimOut(clientSlot, No2AllArtClientOnStart.class);
react.claimOut(clientSlot, No2AllArtClientOnOpen.class);
react.claimOut(clientSlot, No2AllArtClientOnClose.class);
react.claimOut(clientSlot, No2AllArtClientOnError.class);
react.claimOut(clientSlot, No2AllArtClientOnMessage.class);
react.claimOut(clientSlot, No2AllArtClientOnBinary.class);
react.claimOut(clientSlot, WireClient.class);
react.registrate(clientSlot, No2AllActClientConnect.class, v -> {
client.connect();
});
react.registrate(clientSlot, No2AllActClientClose.class, v -> {
client.close(v.getData().getCode(), v.getData().getMessage());
});
react.registrate(clientSlot, No2AllActClientSendMessage.class, v -> {
client.sendMessage(v.getData().getMessage());
});
react.registrate(clientSlot, No2AllActClientSendBinary.class, v -> {
client.sendBinary(v.getData().getMessage());
});
react.fire(API, new No2AllArtClient(clientSlot));
react.fire(clientSlot, client);
});
}
private WireClientHandler wireHandler(No2AllReact react, No2AllReactSlot clientSlot) {
return new WireClientHandler() {
@Override
public void onStart() {
react.fire(clientSlot, new No2AllArtClientOnStart(clientSlot));
}
@Override
public void onOpen() {
react.fire(clientSlot, new No2AllArtClientOnOpen());
}
@Override
public void onClose(int code, String reason, boolean remote) {
react.fire(clientSlot, new No2AllArtClientOnClose(code, reason, remote));
}
@Override
public void onError(Throwable error) {
react.fire(clientSlot, new No2AllArtClientOnError(error));
}
@Override
public void onMessage(String message) {
react.fire(clientSlot, new No2AllArtClientOnMessage(message));
}
@Override
public void onBinary(ByteBuffer message) {
react.fire(clientSlot, new No2AllArtClientOnBinary(message));
}
};
}
}

View file

@ -0,0 +1,16 @@
package love.distributedrebirth.no2all.react.wire.server;
import love.distributedrebirth.no2all.wire.WireServerEndpoint;
public final class No2AllActServer {
private final WireServerEndpoint endpoint;
public No2AllActServer(WireServerEndpoint endpoint) {
this.endpoint = endpoint;
}
public WireServerEndpoint getEndpoint() {
return endpoint;
}
}

View file

@ -0,0 +1,16 @@
package love.distributedrebirth.no2all.react.wire.server;
import java.nio.ByteBuffer;
public final class No2AllActServerBroadcastBinary {
private final ByteBuffer message;
public No2AllActServerBroadcastBinary(ByteBuffer message) {
this.message = message;
}
public ByteBuffer getMessage() {
return message;
}
}

View file

@ -0,0 +1,14 @@
package love.distributedrebirth.no2all.react.wire.server;
public final class No2AllActServerBroadcastMessage {
private final String message;
public No2AllActServerBroadcastMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}

View file

@ -0,0 +1,28 @@
package love.distributedrebirth.no2all.react.wire.server;
public final class No2AllActServerSocketClose {
private final int code;
private final String messag;
public No2AllActServerSocketClose(int code, String message) {
this.code = code;
this.messag = message;
}
public int getCode() {
return code;
}
public String getMessage() {
return messag;
}
public static No2AllActServerSocketClose ofNormal(String message) {
return new No2AllActServerSocketClose(1000, message);
}
public static No2AllActServerSocketClose ofRefuse(String message) {
return new No2AllActServerSocketClose(1003, message);
}
}

View file

@ -0,0 +1,16 @@
package love.distributedrebirth.no2all.react.wire.server;
import java.nio.ByteBuffer;
public final class No2AllActServerSocketSendBinary {
private final ByteBuffer message;
public No2AllActServerSocketSendBinary(ByteBuffer message) {
this.message = message;
}
public ByteBuffer getMessage() {
return message;
}
}

View file

@ -0,0 +1,14 @@
package love.distributedrebirth.no2all.react.wire.server;
public final class No2AllActServerSocketSendMessage {
private final String message;
public No2AllActServerSocketSendMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}

View file

@ -0,0 +1,11 @@
package love.distributedrebirth.no2all.react.wire.server;
import love.distributedrebirth.no2all.react.No2AllReactSlot;
import love.distributedrebirth.no2all.react.warp.No2AllActAbstractSlot;
public final class No2AllArtServer extends No2AllActAbstractSlot {
protected No2AllArtServer(No2AllReactSlot slot) {
super(slot);
}
}

View file

@ -0,0 +1,14 @@
package love.distributedrebirth.no2all.react.wire.server;
public final class No2AllArtServerOnError {
private final Throwable error;
protected No2AllArtServerOnError(Throwable error) {
this.error = error;
}
public Throwable getError() {
return error;
}
}

View file

@ -0,0 +1,7 @@
package love.distributedrebirth.no2all.react.wire.server;
public final class No2AllArtServerOnStart {
protected No2AllArtServerOnStart() {
}
}

View file

@ -0,0 +1,18 @@
package love.distributedrebirth.no2all.react.wire.server;
import love.distributedrebirth.no2all.react.No2AllReactSlot;
import love.distributedrebirth.no2all.react.warp.No2AllActAbstractSlot;
public final class No2AllArtServerSocket extends No2AllActAbstractSlot {
private final String remoteAddr;
protected No2AllArtServerSocket(No2AllReactSlot slot, String remoteAddr) {
super(slot);
this.remoteAddr = remoteAddr;
}
public String getRemoteAddr() {
return remoteAddr;
}
}

View file

@ -0,0 +1,16 @@
package love.distributedrebirth.no2all.react.wire.server;
import java.nio.ByteBuffer;
public final class No2AllArtServerSocketOnBinary {
private final ByteBuffer message;
protected No2AllArtServerSocketOnBinary(ByteBuffer message) {
this.message = message;
}
public ByteBuffer getMessage() {
return message;
}
}

View file

@ -0,0 +1,26 @@
package love.distributedrebirth.no2all.react.wire.server;
public final class No2AllArtServerSocketOnClose {
private final int code;
private final String reason;
private final boolean remote;
protected No2AllArtServerSocketOnClose(int code, String reason, boolean remote) {
this.code = code;
this.reason = reason;
this.remote = remote;
}
public int getCode() {
return code;
}
public String getReason() {
return reason;
}
public boolean isRemote() {
return remote;
}
}

View file

@ -0,0 +1,14 @@
package love.distributedrebirth.no2all.react.wire.server;
public final class No2AllArtServerSocketOnError {
private final Throwable error;
protected No2AllArtServerSocketOnError(Throwable error) {
this.error = error;
}
public Throwable getError() {
return error;
}
}

View file

@ -0,0 +1,14 @@
package love.distributedrebirth.no2all.react.wire.server;
public final class No2AllArtServerSocketOnMessage {
private final String message;
protected No2AllArtServerSocketOnMessage(String message) {
this.message = message;
}
public String getMessage() {
return message;
}
}

View file

@ -0,0 +1,108 @@
package love.distributedrebirth.no2all.react.wire.server;
import java.nio.ByteBuffer;
import love.distributedrebirth.no2all.react.No2AllReactSlotLoad;
import love.distributedrebirth.no2all.react.No2AllReact;
import love.distributedrebirth.no2all.react.No2AllReactSlot;
import love.distributedrebirth.no2all.react.No2AllReactSlotSignal;
import love.distributedrebirth.no2all.react.No2AllReactTypeScript;
import love.distributedrebirth.no2all.wire.WireServer;
import love.distributedrebirth.no2all.wire.WireServerEndpoint;
import love.distributedrebirth.no2all.wire.WireServerHandler;
import love.distributedrebirth.no2all.wire.WireServerSocket;
public class No2AllRtsServer implements No2AllReactTypeScript {
public static final No2AllReactSlot API = No2AllReactSlot.ofClass(No2AllRtsServer.class);
@Override
public void onEvent(No2AllReactSlotSignal<No2AllReactSlotLoad> signal) {
No2AllReact react = signal.getReact();
react.claim(API);
react.claimIn(API, No2AllActServer.class);
react.claimOut(API, No2AllArtServer.class);
react.registrate(API, No2AllActServer.class, actServer -> {
WireServerEndpoint serverEndpoint = actServer.getData().getEndpoint();
No2AllReactSlot serverSlot = No2AllReactSlot.of(API, "wireId=" + serverEndpoint.wireId());
WireServer server = serverEndpoint.wireServer(wireHandler(react, serverSlot));
react.claim(serverSlot);
react.claimIn(serverSlot, No2AllActServerBroadcastMessage.class);
react.claimIn(serverSlot, No2AllActServerBroadcastBinary.class);
react.claimOut(serverSlot, No2AllArtServerOnStart.class);
react.claimOut(serverSlot, No2AllArtServerSocket.class);
react.claimOut(serverSlot, No2AllArtServerOnError.class);
react.claimOut(serverSlot, WireServer.class);
react.registrate(serverSlot, No2AllActServerBroadcastMessage.class, v -> {
server.broadcastMessage(v.getData().getMessage());
});
react.registrate(serverSlot, No2AllActServerBroadcastBinary.class, v -> {
server.broadcastBinary(v.getData().getMessage());
});
react.fire(API, new No2AllArtServer(serverSlot));
react.fire(serverSlot, server);
});
}
private WireServerHandler wireHandler(No2AllReact react, No2AllReactSlot serverSlot) {
return new WireServerHandler() {
private No2AllReactSlot socketSlug(WireServerSocket conn) {
return No2AllReactSlot.of(serverSlot, "hashCode=" + conn.hashCode());
}
@Override
public void onStart() {
react.fire(serverSlot, new No2AllArtServerOnStart());
}
@Override
public void onOpen(WireServerSocket conn) {
No2AllReactSlot socketSlot = socketSlug(conn);
react.claim(socketSlot);
react.claimIn(socketSlot, No2AllActServerSocketSendMessage.class);
react.claimIn(socketSlot, No2AllActServerSocketSendBinary.class);
react.claimIn(socketSlot, No2AllActServerSocketClose.class);
react.claimOut(socketSlot, No2AllArtServerSocketOnClose.class);
react.claimOut(socketSlot, No2AllArtServerSocketOnError.class);
react.claimOut(socketSlot, No2AllArtServerSocketOnMessage.class);
react.claimOut(socketSlot, No2AllArtServerSocketOnBinary.class);
react.registrate(socketSlot, No2AllActServerSocketSendMessage.class, v -> {
conn.sendMessage(v.getData().getMessage());
});
react.registrate(socketSlot, No2AllActServerSocketSendBinary.class, v -> {
conn.sendBinary(v.getData().getMessage());
});
react.registrate(socketSlot, No2AllActServerSocketClose.class, v -> {
conn.close(v.getData().getCode(), v.getData().getMessage());
});
react.fire(serverSlot, new No2AllArtServerSocket(socketSlot, conn.getRemoteAddress()));
}
@Override
public void onClose(WireServerSocket conn, int code, String reason, boolean remote) {
No2AllReactSlot socketSlot = socketSlug(conn);
react.fire(socketSlot, new No2AllArtServerSocketOnClose(code, reason, remote));
react.release(socketSlot);
}
@Override
public void onError(WireServerSocket conn, Throwable error) {
if (conn != null) {
react.fire(socketSlug(conn), new No2AllArtServerSocketOnError(error));
} else {
react.fire(serverSlot, new No2AllArtServerOnError(error));
}
}
@Override
public void onMessage(WireServerSocket conn, String message) {
react.fire(socketSlug(conn), new No2AllArtServerSocketOnMessage(message));
}
@Override
public void onBinary(WireServerSocket conn, ByteBuffer message) {
react.fire(socketSlug(conn), new No2AllArtServerSocketOnBinary(message));
}
};
}
}

View file

@ -0,0 +1,34 @@
package love.distributedrebirth.no2all.react.wire.server;
import love.distributedrebirth.no2all.react.No2AllReactSlotLoad;
import love.distributedrebirth.no2all.react.No2AllReact;
import love.distributedrebirth.no2all.react.No2AllReactSlot;
import love.distributedrebirth.no2all.react.No2AllReactSlotSignal;
import love.distributedrebirth.no2all.react.No2AllReactTypeScript;
public class No2AllRtsServerLog implements No2AllReactTypeScript {
public static final No2AllReactSlot API = No2AllReactSlot.ofClass(No2AllRtsServerLog.class);
@Override
public void onEvent(No2AllReactSlotSignal<No2AllReactSlotLoad> signal) {
No2AllReact react = signal.getReact();
react.claim(API);
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());
});
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());
});
react.registrate(socketSlot, No2AllActServerSocketSendMessage.class, z -> {
System.out.println("No2AllRtsServerLog."+wireId+".socketSendMessage: " + z.getData().getMessage());
});
});
});
}
}