mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-20 00:51:41 +00:00
33 lines
866 B
Java
33 lines
866 B
Java
package com.chameleonvision.web;
|
|
|
|
import com.chameleonvision.settings.SettingsManager;
|
|
import io.javalin.Javalin;
|
|
|
|
|
|
public class Server {
|
|
public static ServerHandler handler;
|
|
|
|
public static void main(int port) {
|
|
handler = new ServerHandler();
|
|
|
|
Javalin app = Javalin.create();
|
|
|
|
app.config.addStaticFiles("web");
|
|
app.ws("/websocket", ws -> {
|
|
ws.onConnect(ctx -> {
|
|
handler.onConnect(ctx);
|
|
System.out.println("Socket Connected");
|
|
});
|
|
ws.onClose(ctx -> {
|
|
handler.onClose(ctx);
|
|
System.out.println("Socket Disconnected");
|
|
SettingsManager.saveSettings();
|
|
});
|
|
ws.onBinaryMessage(ctx -> {
|
|
handler.onBinaryMessage(ctx);
|
|
});
|
|
});
|
|
|
|
app.start(port);
|
|
}
|
|
} |