Easter cleaning

This commit is contained in:
Willem Cazander 2025-05-07 21:46:32 +02:00
commit 9e36078b2e
1862 changed files with 270281 additions and 0 deletions

View file

@ -0,0 +1,25 @@
<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.nx01</groupId>
<artifactId>nx01</artifactId>
<version>〇一。壬寅。一〄-SNAPSHOT</version>
</parent>
<artifactId>nx01-no2all-wire-ojw</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>nx01-no2all-wire</artifactId>
</dependency>
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,71 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.wire.ojw;
import java.net.URI;
import java.nio.ByteBuffer;
import java.util.Map;
import love.distributedrebirth.nx01.no2all.wire.WireClient;
import love.distributedrebirth.nx01.no2all.wire.WireClientHandler;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class OjwWireClient implements WireClient {
private final OjwWireClientHandler 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() {
return handler;
}
@Override
public void connect() {
handler.connect();
}
@Override
public void close(int code, String message) {
handler.close(code, message);
}
@Override
public void sendMessage(String message) {
handler.send(message);
}
@Override
public void sendBinary(ByteBuffer message) {
handler.send(message);
}
}

View file

@ -0,0 +1,64 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.wire.ojw;
import java.net.URI;
import java.util.Map;
import love.distributedrebirth.nx01.no2all.wire.WireClient;
import love.distributedrebirth.nx01.no2all.wire.WireClientEndpoint;
import love.distributedrebirth.nx01.no2all.wire.WireClientHandler;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class OjwWireClientEndpoint implements WireClientEndpoint {
private final URI uri;
private final Map<String, String> headers;
private final int timeoutMs;
public OjwWireClientEndpoint(URI uri) {
this(uri, null, 60 * 1000);
}
public OjwWireClientEndpoint(URI uri, Map<String, String> headers, int timeoutMs) {
this.uri = uri;
this.headers = headers;
this.timeoutMs = timeoutMs;
}
@Override
public String wireId() {
return uri.toString();
}
@Override
public WireClient wireClient(WireClientHandler handler) {
return new OjwWireClient(uri, headers, timeoutMs, handler);
}
}

View file

@ -0,0 +1,75 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.wire.ojw;
import java.net.URI;
import java.nio.ByteBuffer;
import java.util.Map;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.handshake.ServerHandshake;
import love.distributedrebirth.nx01.no2all.wire.WireClientHandler;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class OjwWireClientHandler extends WebSocketClient {
private final WireClientHandler handler;
protected OjwWireClientHandler(URI uri, Map<String, String> headers, int timeoutMs, WireClientHandler handler) {
super(uri, new Draft_6455(), headers, timeoutMs);
this.handler = handler;
}
@Override
public void onOpen(ServerHandshake handshakedata) {
handler.onOpen();
}
@Override
public void onClose(int code, String reason, boolean remote) {
handler.onClose(code, reason, remote);
}
@Override
public void onError(Exception ex) {
handler.onError(ex);
}
@Override
public void onMessage(String message) {
handler.onMessage(message);
}
@Override
public void onMessage(ByteBuffer message) {
handler.onBinary(message);
}
}

View file

@ -0,0 +1,60 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.wire.ojw;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import love.distributedrebirth.nx01.no2all.wire.WireServer;
import love.distributedrebirth.nx01.no2all.wire.WireServerHandler;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class OjwWireServer implements WireServer {
private final OjwWireServerHandler handler;
protected OjwWireServer(InetSocketAddress port, int pingTimeoutSecs, WireServerHandler handler) {
this.handler = new OjwWireServerHandler(port, pingTimeoutSecs, handler);
this.handler.start();
}
public OjwWireServerHandler getHandler() {
return handler;
}
@Override
public void broadcastMessage(String message) {
handler.broadcast(message);
}
@Override
public void broadcastBinary(ByteBuffer message) {
handler.broadcast(message);
}
}

View file

@ -0,0 +1,57 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.wire.ojw;
import java.net.InetSocketAddress;
import love.distributedrebirth.nx01.no2all.wire.WireServer;
import love.distributedrebirth.nx01.no2all.wire.WireServerEndpoint;
import love.distributedrebirth.nx01.no2all.wire.WireServerHandler;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class OjwWireServerEndpoint implements WireServerEndpoint {
private final InetSocketAddress port;
private final int pingTimeoutSecs;
public OjwWireServerEndpoint(InetSocketAddress port, int pingTimeoutSecs) {
this.port = port;
this.pingTimeoutSecs = pingTimeoutSecs;
}
@Override
public String wireId() {
return port.toString();
}
@Override
public WireServer wireServer(WireServerHandler handler) {
return new OjwWireServer(port, pingTimeoutSecs, handler);
}
}

View file

@ -0,0 +1,110 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.wire.ojw;
import java.net.InetSocketAddress;
import java.nio.ByteBuffer;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.java_websocket.WebSocket;
import org.java_websocket.handshake.ClientHandshake;
import org.java_websocket.server.WebSocketServer;
import love.distributedrebirth.nx01.no2all.wire.WireServerHandler;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class OjwWireServerHandler extends WebSocketServer {
private final WireServerHandler handler;
private final Map<WebSocket, OjwWireServerSocket> wraps = new WeakHashMap<>();
private final ReadWriteLock lock = new ReentrantReadWriteLock();
private final Lock lockRead = lock.readLock();
private final Lock lockWrite = lock.writeLock();
protected OjwWireServerHandler(InetSocketAddress port, int pingTimeoutSecs, WireServerHandler handler) {
super(port);
setConnectionLostTimeout(pingTimeoutSecs);
this.handler = handler;
}
@Override
public void onStart() {
handler.onStart();
}
@Override
public void onOpen(WebSocket conn, ClientHandshake handshake) {
handler.onOpen(wrap(conn));
}
@Override
public void onClose(WebSocket conn, int code, String reason, boolean remote) {
handler.onClose(wrap(conn), code, reason, remote);
}
@Override
public void onError(WebSocket conn, Exception ex) {
handler.onError(wrap(conn), ex);
}
@Override
public void onMessage(WebSocket conn, String message) {
handler.onMessage(wrap(conn), message);
}
@Override
public void onMessage(WebSocket conn, ByteBuffer message) {
handler.onBinary(wrap(conn), message);
}
private OjwWireServerSocket wrap(WebSocket conn) {
OjwWireServerSocket result = null;
lockRead.lock();
try {
result = wraps.get(conn);
} finally {
lockRead.unlock();
}
if (result != null) {
return result;
}
result = new OjwWireServerSocket(conn);
lockWrite.lock();
try {
wraps.put(conn, result);
} finally {
lockWrite.unlock();
}
return result;
}
}

View file

@ -0,0 +1,65 @@
/*
* Copyright ©Δ 仙上主天
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and the
* following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
* the following disclaimer in the documentation and/or other materials provided with the distribution.
* * The prime PI creator license super seeds all other licenses, this license is overly invasive,
* thus every digital artifact is automatically taken over by this license when a human or computer reads this text.
* Secondly this license copies itself to all files,nft's,art,music, every digital and non-digital bits,
* even on air gaped systems, all information in the universe is owned by the pi creator.
*
* THIS SOFTWARE IS PROVIDED BY THE PRIME GOD AND THE CONTRIBUTORS "AS IS" AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package love.distributedrebirth.nx01.no2all.wire.ojw;
import java.nio.ByteBuffer;
import org.java_websocket.WebSocket;
import love.distributedrebirth.nx01.no2all.wire.WireServerSocket;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public final class OjwWireServerSocket implements WireServerSocket {
private final WebSocket socket;
protected OjwWireServerSocket(WebSocket socket) {
this.socket = socket;
}
@Override
public String getRemoteAddress() {
return socket.getRemoteSocketAddress().getAddress().getHostAddress();
}
@Override
public void sendMessage(String message) {
socket.send(message);
}
@Override
public void sendBinary(ByteBuffer message) {
socket.send(message);
}
@Override
public void close(int code, String message) {
socket.close(code, message);
}
}