Skip to content

Commit

Permalink
Server: Move everything into a package that makes more sense.
Browse files Browse the repository at this point in the history
  • Loading branch information
e3ndr committed Oct 2, 2023
1 parent d3d597b commit 0ad6547
Show file tree
Hide file tree
Showing 19 changed files with 40 additions and 39 deletions.
12 changes: 6 additions & 6 deletions server/src/main/java/xyz/e3ndr/athena/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
import co.casterlabs.rakurai.json.Rson;
import co.casterlabs.rakurai.json.serialization.JsonParseException;
import co.casterlabs.sora.SoraFramework;
import xyz.e3ndr.athena.server.ftp.AthenaFtpServer;
import xyz.e3ndr.athena.server.http.AthenaHttpServer;
import xyz.e3ndr.athena.webui.AthenaUIServer;
import xyz.e3ndr.athena.service.ftp.AthenaFtpServer;
import xyz.e3ndr.athena.service.http.AthenaHttpServer;
import xyz.e3ndr.athena.service.simple_ui.AthenaSimpleUIServer;
import xyz.e3ndr.fastloggingframework.FastLoggingFramework;
import xyz.e3ndr.fastloggingframework.logging.FastLogger;
import xyz.e3ndr.fastloggingframework.logging.LogLevel;
Expand Down Expand Up @@ -48,15 +48,15 @@ public static void main(String[] args) throws Exception {

// Go!
if (Athena.config.services.http.enable) {
AsyncTask.createNonDaemon(() -> new AthenaHttpServer().start());
AsyncTask.createNonDaemon(() -> new AthenaHttpServer().init());
}

if (Athena.config.services.http.enable) {
AsyncTask.createNonDaemon(() -> new AthenaFtpServer().start());
AsyncTask.createNonDaemon(() -> new AthenaFtpServer().init());
}

if (Athena.config.services.simpleUI.enable) {
AsyncTask.createNonDaemon(() -> new AthenaUIServer().start());
AsyncTask.createNonDaemon(() -> new AthenaSimpleUIServer().init());
}
}

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package xyz.e3ndr.athena.service;

public interface AthenaService {

public void init();

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.webui;
package xyz.e3ndr.athena.service;

import java.util.Arrays;
import java.util.LinkedList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.server.ftp;
package xyz.e3ndr.athena.service.ftp;

import java.io.IOException;
import java.net.ServerSocket;
Expand All @@ -8,7 +8,7 @@
import java.util.List;

import xyz.e3ndr.athena.Athena;
import xyz.e3ndr.athena.server.AthenaServer;
import xyz.e3ndr.athena.service.AthenaService;
import xyz.e3ndr.fastloggingframework.logging.FastLogger;
import xyz.e3ndr.fastloggingframework.logging.LogLevel;

Expand All @@ -17,14 +17,14 @@
*
* @author Moritz Stueckler
*/
public class AthenaFtpServer implements AthenaServer {
public class AthenaFtpServer implements AthenaService {
private static final int MAX_CLIENTS = 100;
private static final int FTP_PORT_RANGE_OFFSET = 100;
static final List<Integer> openPorts = Collections.synchronizedList(new LinkedList<>());

@SuppressWarnings("resource")
@Override
public void start() {
public void init() {
int controlPort = Athena.config.services.ftp.port;

// Generate a list of ports.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.server.ftp;
package xyz.e3ndr.athena.service.ftp;

import java.io.BufferedReader;
import java.io.Closeable;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.server.ftp;
package xyz.e3ndr.athena.service.ftp;

enum LoginState {
WAITING_FOR_USERNAME,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.server.ftp;
package xyz.e3ndr.athena.service.ftp;

enum TransferType {
ASCII,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.server.http;
package xyz.e3ndr.athena.service.http;

import org.jetbrains.annotations.Nullable;

Expand All @@ -8,14 +8,14 @@
import co.casterlabs.sora.api.SoraPlugin;
import lombok.NonNull;
import xyz.e3ndr.athena.Athena;
import xyz.e3ndr.athena.server.AthenaServer;
import xyz.e3ndr.athena.service.AthenaService;
import xyz.e3ndr.fastloggingframework.logging.FastLogger;
import xyz.e3ndr.fastloggingframework.logging.LogLevel;

public class AthenaHttpServer implements AthenaServer {
public class AthenaHttpServer implements AthenaService {

@Override
public void start() {
public void init() {
try {
int port = Athena.config.services.http.port;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.server.http;
package xyz.e3ndr.athena.service.http;

import java.io.IOException;
import java.io.OutputStream;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.server.http;
package xyz.e3ndr.athena.service.http;

import java.nio.charset.StandardCharsets;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.server.http;
package xyz.e3ndr.athena.service.http;

import java.util.Arrays;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.server.http;
package xyz.e3ndr.athena.service.http;

import co.casterlabs.rakurai.io.http.StandardHttpStatus;
import co.casterlabs.rakurai.io.http.server.HttpResponse;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.server.http;
package xyz.e3ndr.athena.service.http;

import java.util.Arrays;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.server.http;
package xyz.e3ndr.athena.service.http;

import java.io.File;
import java.io.IOException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.server.http;
package xyz.e3ndr.athena.service.http;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.webui;
package xyz.e3ndr.athena.service.simple_ui;

import org.jetbrains.annotations.Nullable;

Expand All @@ -8,14 +8,14 @@
import co.casterlabs.sora.api.SoraPlugin;
import lombok.NonNull;
import xyz.e3ndr.athena.Athena;
import xyz.e3ndr.athena.server.AthenaServer;
import xyz.e3ndr.athena.service.AthenaService;
import xyz.e3ndr.fastloggingframework.logging.FastLogger;
import xyz.e3ndr.fastloggingframework.logging.LogLevel;

public class AthenaUIServer implements AthenaServer {
public class AthenaSimpleUIServer implements AthenaService {

@Override
public void start() {
public void init() {
try {
int port = Athena.config.services.simpleUI.port;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package xyz.e3ndr.athena.webui;
package xyz.e3ndr.athena.service.simple_ui;

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.server.http.StreamRoutes;
import xyz.e3ndr.athena.service.http.StreamRoutes;

class InternalRoutes implements HttpProvider {
private StreamRoutes streamRoutes = new StreamRoutes();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package xyz.e3ndr.athena.webui;
package xyz.e3ndr.athena.service.simple_ui;

import java.net.HttpURLConnection;
import java.net.URL;
Expand All @@ -24,6 +24,7 @@
import co.casterlabs.sora.api.http.annotations.HttpEndpoint;
import lombok.SneakyThrows;
import xyz.e3ndr.athena.Athena;
import xyz.e3ndr.athena.service.HTMLBuilder;
import xyz.e3ndr.athena.types.AudioCodec;
import xyz.e3ndr.athena.types.ContainerFormat;
import xyz.e3ndr.athena.types.VideoCodec;
Expand Down

0 comments on commit 0ad6547

Please sign in to comment.