-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Server: Start transitioning web-simple into Athena.
- Loading branch information
Showing
4 changed files
with
111 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
server/src/main/java/xyz/e3ndr/athena/webui/AthenaUIServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package xyz.e3ndr.athena.webui; | ||
|
||
import org.jetbrains.annotations.Nullable; | ||
|
||
import co.casterlabs.sora.Sora; | ||
import co.casterlabs.sora.SoraFramework; | ||
import co.casterlabs.sora.SoraLauncher; | ||
import co.casterlabs.sora.api.SoraPlugin; | ||
import lombok.NonNull; | ||
import xyz.e3ndr.athena.Config; | ||
import xyz.e3ndr.athena.server.AthenaServer; | ||
import xyz.e3ndr.fastloggingframework.logging.FastLogger; | ||
import xyz.e3ndr.fastloggingframework.logging.LogLevel; | ||
|
||
public class AthenaUIServer implements AthenaServer { | ||
|
||
@Override | ||
public void start(Config config) { | ||
try { | ||
int port = config.getWebUiPort(); | ||
|
||
if (port == -1) return; | ||
|
||
SoraFramework framework = new SoraLauncher() | ||
.setPort(port) | ||
.buildWithoutPluginLoader(); | ||
|
||
framework | ||
.getSora() | ||
.register(new AthenaSoraAdapter()); | ||
|
||
framework | ||
.getServer() | ||
.getLogger() | ||
.setCurrentLevel(LogLevel.WARNING); | ||
|
||
framework.startHttpServer(); | ||
|
||
FastLogger.logStatic("Started http server on %d!", port); | ||
} catch (Exception e) { | ||
FastLogger.logStatic(LogLevel.SEVERE, "Unable to start http server:\n%s", e); | ||
} | ||
} | ||
|
||
public static class AthenaSoraAdapter extends SoraPlugin { | ||
|
||
@Override | ||
public void onInit(Sora sora) { | ||
} | ||
|
||
@Override | ||
public void onClose() {} | ||
|
||
@Override | ||
public @Nullable String getVersion() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public @Nullable String getAuthor() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public @NonNull String getName() { | ||
return "Athena Web UI"; | ||
} | ||
|
||
@Override | ||
public @NonNull String getId() { | ||
return "athena-webui"; | ||
} | ||
|
||
} | ||
|
||
} |