diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml
index fefacc1..eefd497 100644
--- a/.idea/inspectionProfiles/Project_Default.xml
+++ b/.idea/inspectionProfiles/Project_Default.xml
@@ -7,9 +7,11 @@
+
+
diff --git a/EWS_POC.iml b/EWS_POC.iml
index e8fb9ea..08a455a 100644
--- a/EWS_POC.iml
+++ b/EWS_POC.iml
@@ -14,7 +14,7 @@
-
+
\ No newline at end of file
diff --git a/src/Main.kt b/src/Main.kt
index 3eda42f..ee06f47 100644
--- a/src/Main.kt
+++ b/src/Main.kt
@@ -1,6 +1,7 @@
import audio.AudioUtility
import audio.OpusStreamReceiver
import somecodes.Codes.Companion.ValidString
+import web.webApp
import zello.ZelloClient
import zello.ZelloEvent
@@ -23,6 +24,9 @@ fun main() {
val o = OpusStreamReceiver(audioID)
+ val w = webApp("0.0.0.0",3030, javafx.util.Pair("admin","admin1234"))
+ w.Start()
+
val z = ZelloClient.fromConsumerZello("gtcdevice01","GtcDev2025")
z.Start(object : ZelloEvent {
override fun onChannelStatus(
diff --git a/src/web/webApp.java b/src/web/webApp.java
new file mode 100644
index 0000000..a2ca713
--- /dev/null
+++ b/src/web/webApp.java
@@ -0,0 +1,122 @@
+package web;
+
+import io.javalin.Javalin;
+import javafx.util.Pair;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import static io.javalin.apibuilder.ApiBuilder.*;
+
+public class webApp {
+ private final Javalin app;
+ private final String listenAddress;
+ private final int listenPort;
+ private final Logger logger = LoggerFactory.getLogger(webApp.class);
+ private final Map usermap = new HashMap<>();
+ public webApp(String listenAddress, int listenPort, Pair... users) {
+ this.listenAddress = listenAddress;
+ this.listenPort = listenPort;
+ if (users != null){
+ for (Pair user : users) {
+ this.usermap.put(user.getKey(), user.getValue());
+ }
+ }
+ app = Javalin.create(config -> {
+ config.useVirtualThreads = true; // Enable virtual threads for better performance
+ config.staticFiles.add("/");
+ config.router.apiBuilder(()->{
+ path("/", () -> get(ctx -> {
+ if (ctx.sessionAttribute("user") == null) {
+ ctx.redirect("/index.html");
+ } else {
+ ctx.redirect("/pocreceiver.html");
+ }
+ }));
+ path("/index.html", ()-> {
+ before( ctx ->{
+ ctx.sessionAttribute("user", null); // Clear user session on index page
+ });
+ post(ctx-> {
+ var username = ctx.formParam("username");
+ var password = ctx.formParam("password");
+ var xx = usermap.get(username);
+ if (xx != null && xx.equals(password)) {
+ ctx.sessionAttribute("user", username);
+ ctx.redirect("/pocreceiver.html");
+ } else {
+ ctx.result("Invalid username or password");
+ }
+ });
+ });
+ path("/pocreceiver.html", ()->{
+ before(ctx -> {
+ if (ctx.sessionAttribute("user") == null) {
+ ctx.redirect("/index.html");
+ }
+ });
+ ws("/ws", wshandler -> wshandler.onMessage(wsMessageContext -> {
+ // Handle incoming WebSocket messages
+ String message = wsMessageContext.message();
+ // Process the message as needed
+ }));
+ });
+ path("/prerecordedbroadcast.html", ()->{
+ before(ctx -> {
+ if (ctx.sessionAttribute("user") == null) {
+ ctx.redirect("/index.html");
+ }
+ });
+ ws("/ws", wshandler -> wshandler.onMessage(wsMessageContext -> {
+ // Handle incoming WebSocket messages
+ String message = wsMessageContext.message();
+ // Process the message as needed
+ }));
+ });
+ path("/setting.html", () ->{
+ before(ctx -> {
+ if (ctx.sessionAttribute("user") == null) {
+ ctx.redirect("/index.html");
+ }
+ });
+ ws("/ws", wshandler -> wshandler.onMessage(wsMessageContext -> {
+ // Handle incoming WebSocket messages
+ String message = wsMessageContext.message();
+ // Process the message as needed
+ }));
+ });
+
+ });
+ });
+
+ }
+
+ /**
+ * Start the web application.
+ */
+ public boolean Start(){
+ try{
+ app.start(listenAddress, listenPort);
+ return true;
+ } catch (Exception e){
+ logger.error("webApp start failed", e.getMessage());
+ }
+ return false;
+
+ }
+
+ /**
+ * Stop the web application.
+ */
+ public void Stop(){
+ try{
+ app.stop();
+ logger.info("webApp stopped");
+ } catch (Exception e){
+ logger.error("webApp stop failed", e.getMessage());
+ }
+
+ }
+}