-
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: Move the WiiMC routes into a dedicated service.
- Loading branch information
Showing
6 changed files
with
107 additions
and
8 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/service/special/AthenaSpecialServer.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.service.special; | ||
|
||
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.Athena; | ||
import xyz.e3ndr.athena.service.AthenaService; | ||
import xyz.e3ndr.fastloggingframework.logging.FastLogger; | ||
import xyz.e3ndr.fastloggingframework.logging.LogLevel; | ||
|
||
public class AthenaSpecialServer implements AthenaService { | ||
|
||
@Override | ||
public void init() { | ||
try { | ||
int port = Athena.config.services.http.port; | ||
|
||
SoraFramework framework = new SoraLauncher() | ||
.setPort(port) | ||
.buildWithoutPluginLoader(); | ||
|
||
framework | ||
.getSora() | ||
.register(new AthenaSoraAdapter()); | ||
|
||
framework | ||
.getServer() | ||
.getLogger() | ||
.setCurrentLevel(LogLevel.WARNING); | ||
|
||
framework.startHttpServer(); | ||
|
||
FastLogger.logStatic("Started special server on %d!", port); | ||
} catch (Exception e) { | ||
FastLogger.logStatic(LogLevel.SEVERE, "Unable to start special server:\n%s", e); | ||
} | ||
} | ||
|
||
static class AthenaSoraAdapter extends SoraPlugin { | ||
|
||
@Override | ||
public void onInit(Sora sora) { | ||
sora.addProvider(this, new WiiMCRoutes()); | ||
sora.addProvider(this, new InternalRoutes()); | ||
} | ||
|
||
@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"; | ||
} | ||
|
||
@Override | ||
public @NonNull String getId() { | ||
return "athena"; | ||
} | ||
|
||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
server/src/main/java/xyz/e3ndr/athena/service/special/InternalRoutes.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,17 @@ | ||
package xyz.e3ndr.athena.service.special; | ||
|
||
import co.casterlabs.rakurai.io.http.server.HttpResponse; | ||
import co.casterlabs.sora.api.http.HttpProvider; | ||
import co.casterlabs.sora.api.http.SoraHttpSession; | ||
import co.casterlabs.sora.api.http.annotations.HttpEndpoint; | ||
import xyz.e3ndr.athena.service.http.StreamRoutes; | ||
|
||
class InternalRoutes implements HttpProvider { | ||
private StreamRoutes streamRoutes = new StreamRoutes(); | ||
|
||
@HttpEndpoint(uri = "/_internal/media/:mediaId/stream") | ||
public HttpResponse onStreamRAW(SoraHttpSession session) { | ||
return this.streamRoutes.onStreamRAW(session); | ||
} | ||
|
||
} |
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