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,43 @@
<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-jetty</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>${project.groupId}</groupId>
<artifactId>nx01-no2all-react-wire</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-jetty-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-jetty-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty.websocket</groupId>
<artifactId>websocket-jetty-client</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,99 @@
/*
* 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.jetty;
import java.io.IOException;
import java.net.URI;
import java.nio.ByteBuffer;
import java.util.concurrent.ExecutionException;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.eclipse.jetty.websocket.client.impl.JettyClientUpgradeRequest;
import love.distributedrebirth.nx01.no2all.wire.WireClient;
import love.distributedrebirth.nx01.no2all.wire.WireClientHandler;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class JettyWireClient implements WireClient {
private final URI uri;
private final WebSocketClient client;
private final JettyWireClientHandler handler;
protected JettyWireClient(URI uri, WebSocketClient client, WireClientHandler handler) {
this.uri = uri;
this.client = client;
this.handler = new JettyWireClientHandler(handler);
}
public JettyWireClientHandler getHandler() {
return handler;
}
@Override
public void connect() {
try {
client.connect(handler, uri).get();
} catch (IOException | InterruptedException | ExecutionException e) {
throw new IllegalStateException(e);
}
}
@Override
public void close(int code, String message) {
client.getOpenSessions().forEach(v -> {
JettyClientUpgradeRequest req = JettyClientUpgradeRequest.class.cast(v.getUpgradeRequest());
if (req.getURI().equals(uri)) {
v.close(code, message);
}
});
}
@Override
public void sendMessage(String message) {
client.getOpenSessions().forEach(v -> {
try {
v.getRemote().sendString(message);
} catch (IOException e) {
throw new IllegalStateException(e);
}
});
}
@Override
public void sendBinary(ByteBuffer message) {
client.getOpenSessions().forEach(v -> {
try {
v.getRemote().sendBytes(message);
} catch (IOException e) {
throw new IllegalStateException(e);
}
});
}
}

View file

@ -0,0 +1,59 @@
/*
* 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.jetty;
import java.net.URI;
import org.eclipse.jetty.websocket.client.WebSocketClient;
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 JettyWireClientEndpoint implements WireClientEndpoint {
private final URI uri;
private final WebSocketClient client;
public JettyWireClientEndpoint(URI uri, WebSocketClient client) {
this.uri = uri;
this.client = client;
}
@Override
public String wireId() {
return uri.toString();
}
@Override
public WireClient wireClient(WireClientHandler handler) {
return new JettyWireClient(uri, client, handler);
}
}

View file

@ -0,0 +1,72 @@
/*
* 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.jetty;
import java.nio.ByteBuffer;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketListener;
import love.distributedrebirth.nx01.no2all.wire.WireClientHandler;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class JettyWireClientHandler implements WebSocketListener {
private final WireClientHandler handler;
protected JettyWireClientHandler(WireClientHandler handler) {
this.handler = handler;
this.handler.onStart();
}
@Override
public void onWebSocketConnect(Session session) {
handler.onOpen();
}
@Override
public void onWebSocketClose(int statusCode, String reason) {
handler.onClose(statusCode, reason, false);
}
@Override
public void onWebSocketError(Throwable cause) {
handler.onError(cause);
}
@Override
public void onWebSocketBinary(byte[] payload, int offset, int len) {
handler.onBinary(ByteBuffer.wrap(payload, offset, len));
}
@Override
public void onWebSocketText(String message) {
handler.onMessage(message);
}
}

View file

@ -0,0 +1,70 @@
/*
* 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.jetty;
import java.io.IOException;
import java.nio.ByteBuffer;
import org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer;
import love.distributedrebirth.nx01.no2all.wire.WireServer;
import love.distributedrebirth.nx01.no2all.wire.WireServerHandler;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class JettyWireServer implements WireServer {
private final JettyWebSocketServerContainer wsContainer;
protected JettyWireServer(JettyWebSocketServerContainer wsContainer, String servletPath, WireServerHandler handler) {
this.wsContainer = wsContainer;
this.wsContainer.addMapping(servletPath, new JettyWireServerEndpointCreator(handler));
}
@Override
public void broadcastMessage(String message) {
wsContainer.getOpenSessions().forEach(v -> {
try {
v.getRemote().sendString(message);
} catch (IOException e) {
throw new IllegalStateException(e);
}
});
}
@Override
public void broadcastBinary(ByteBuffer message) {
wsContainer.getOpenSessions().forEach(v -> {
try {
v.getRemote().sendBytes(message);
} catch (IOException e) {
throw new IllegalStateException(e);
}
});
}
}

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.jetty;
import org.eclipse.jetty.websocket.server.JettyWebSocketServerContainer;
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 JettyWireServerEndpoint implements WireServerEndpoint {
private final JettyWebSocketServerContainer wsContainer;
private final String servletPath;
public JettyWireServerEndpoint(JettyWebSocketServerContainer wsContainer, String servletPath) {
this.wsContainer = wsContainer;
this.servletPath = servletPath;
}
@Override
public String wireId() {
return servletPath;
}
@Override
public WireServer wireServer(WireServerHandler handler) {
return new JettyWireServer(wsContainer, servletPath, handler);
}
}

View file

@ -0,0 +1,51 @@
/*
* 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.jetty;
import org.eclipse.jetty.websocket.server.JettyServerUpgradeRequest;
import org.eclipse.jetty.websocket.server.JettyServerUpgradeResponse;
import org.eclipse.jetty.websocket.server.JettyWebSocketCreator;
import love.distributedrebirth.nx01.no2all.wire.WireServerHandler;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class JettyWireServerEndpointCreator implements JettyWebSocketCreator {
private final WireServerHandler handler;
public JettyWireServerEndpointCreator(WireServerHandler handler) {
this.handler = handler;
}
@Override
public Object createWebSocket(JettyServerUpgradeRequest jettyServerUpgradeRequest,
JettyServerUpgradeResponse jettyServerUpgradeResponse) {
return new JettyWireServerHandler(handler);
}
}

View file

@ -0,0 +1,74 @@
/*
* 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.jetty;
import java.nio.ByteBuffer;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.api.WebSocketListener;
import love.distributedrebirth.nx01.no2all.wire.WireServerHandler;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class JettyWireServerHandler implements WebSocketListener {
private final WireServerHandler handler;
private JettyWireServerSocket conn;
protected JettyWireServerHandler(WireServerHandler handler) {
this.handler = handler;
this.handler.onStart();
}
@Override
public void onWebSocketConnect(Session session) {
this.conn = new JettyWireServerSocket(session);
handler.onOpen(conn);
}
@Override
public void onWebSocketClose(int statusCode, String reason) {
handler.onClose(conn, statusCode, reason, false);
}
@Override
public void onWebSocketError(Throwable cause) {
handler.onError(conn, cause);
}
@Override
public void onWebSocketBinary(byte[] payload, int offset, int len) {
handler.onBinary(conn, ByteBuffer.wrap(payload, offset, len));
}
@Override
public void onWebSocketText(String message) {
handler.onMessage(conn, message);
}
}

View file

@ -0,0 +1,74 @@
/*
* 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.jetty;
import java.io.IOException;
import java.nio.ByteBuffer;
import org.eclipse.jetty.websocket.api.Session;
import love.distributedrebirth.nx01.no2all.wire.WireServerSocket;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public final class JettyWireServerSocket implements WireServerSocket {
private final Session session;
protected JettyWireServerSocket(Session session) {
this.session = session;
}
@Override
public String getRemoteAddress() {
return session.getRemoteAddress().toString();
}
@Override
public void sendMessage(String message) {
try {
session.getRemote().sendString(message);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
@Override
public void sendBinary(ByteBuffer message) {
try {
session.getRemote().sendBytes(message);
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
@Override
public void close(int code, String message) {
session.close(code, message);
}
}

View file

@ -0,0 +1,107 @@
/*
* 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.jetty;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.ByteBuffer;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import love.distributedrebirth.nx01.no2all.wire.WireClient;
import love.distributedrebirth.nx01.no2all.wire.WireClientHandler;
import love.distributedrebirth.nx01.no2all.wire.jetty.JettyWireClientEndpoint;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class EventClient implements WireClientHandler {
private static final Logger LOG = LoggerFactory.getLogger(EventClient.class);
public static void main(String[] args) throws Exception {
EventClient client = new EventClient();
client.start();
client.sendHallo();
client.stop();
}
private WebSocketClient client;
private JettyWireClientEndpoint endpoint1;
public EventClient() throws URISyntaxException {
client = new WebSocketClient();
endpoint1 = new JettyWireClientEndpoint(new URI("ws://localhost:8080/ws/text"), client);
}
public void start() throws Exception {
client.start();
LOG.info("client startup");
}
public void stop() throws Exception {
client.stop();
}
public void sendHallo() {
WireClient client1 = endpoint1.wireClient(this);
client1.connect();
client1.sendMessage("test me");
}
@Override
public void onStart() {
LOG.info("client.onStart()");
}
@Override
public void onOpen() {
LOG.info("client.onOpen()");
}
@Override
public void onClose(int code, String reason, boolean remote) {
LOG.info("client.onClose: "+code);
}
@Override
public void onError(Throwable error) {
LOG.info("client.onError: "+error.getMessage());
}
@Override
public void onMessage(String message) {
LOG.info("client.onMessage: "+message);
}
@Override
public void onBinary(ByteBuffer message) {
LOG.info("client.onBinary: "+message);
}
}

View file

@ -0,0 +1,131 @@
/*
* 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.jetty;
import java.net.URI;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.util.component.LifeCycle;
import org.eclipse.jetty.util.component.LifeCycle.Listener;
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllActServer;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllActServerSocketSendMessage;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServer;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServerSocket;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllArtServerSocketOnMessage;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllRtsServer;
import love.distributedrebirth.nx01.no2all.react.wire.server.No2AllRtsServerLog;
import love.distributedrebirth.nx01.no2all.wire.jetty.JettyWireServerEndpoint;
import love.distributedrebirth.nx01.warp.core.WarpCoreReactor;
import love.distributedrebirth.nx01.warp.core.WarpCoreSpeedMonitor;
import love.distributedrebirth.nx01.warp.core.react.WarpReactPlasma;
/// @author للَّٰهِilLצسُو
/// @version ©Δ 仙上主天
public class EventServer {
private static final Logger LOG = LoggerFactory.getLogger(EventServer.class);
public static void main(String[] args) throws Exception {
EventServer server = new EventServer();
server.setPort(8080);
server.start();
server.join();
}
private final Server server;
private final ServerConnector connector;
private JettyWireServerEndpoint endpoint1;
private JettyWireServerEndpoint endpoint2;
private WarpReactPlasma mushroomServer = WarpReactPlasma.ofClass(EventServer.class);
public EventServer() {
server = new Server();
connector = new ServerConnector(server);
server.addConnector(connector);
ServletContextHandler context = new ServletContextHandler(ServletContextHandler.SESSIONS);
context.setContextPath("/");
server.setHandler(context);
JettyWebSocketServletContainerInitializer.configure(context, (servletContext, wsContainer) -> {
wsContainer.setMaxTextMessageSize(65535);
endpoint1 = new JettyWireServerEndpoint(wsContainer, "/ws/text");
endpoint2 = new JettyWireServerEndpoint(wsContainer, "/ws/bin");
});
server.addEventListener(new Listener() {
@Override
public void lifeCycleStarted(LifeCycle event) {
LOG.info("Startup No2AllReactWarpCore");
WarpCoreReactor react = new WarpCoreReactor();
react.claim(mushroomServer);
react.load(new WarpCoreSpeedMonitor());
react.load(new No2AllRtsServer(mushroomServer));
react.load(new No2AllRtsServerLog(mushroomServer));
// auto reply
react.registrate(mushroomServer, No2AllArtServer.class, artServer -> {
WarpReactPlasma serverSlot = artServer.getData().getSlot();
react.registrate(serverSlot, No2AllArtServerSocket.class, artSocket -> {
WarpReactPlasma socketSlot = artSocket.getData().getSlot();
react.registrate(socketSlot, No2AllArtServerSocketOnMessage.class, artMsg -> {
react.fire(socketSlot, new No2AllActServerSocketSendMessage("RE: "+artMsg.getData().getMessage()));
});
});
});
react.fire(mushroomServer, new No2AllActServer(endpoint1));
react.fire(mushroomServer, new No2AllActServer(endpoint2));
}
});
}
public void setPort(int port) {
connector.setPort(port);
}
public void start() throws Exception {
server.start();
}
public URI getURI() {
return server.getURI();
}
public void stop() throws Exception {
server.stop();
}
public void join() throws InterruptedException {
LOG.info("Use Ctrl+C to stop server");
server.join();
}
}