mirror of
https://github.com/Melledy/Nebula.git
synced 2025-12-25 18:54:36 +01:00
Allow the server to send ClientDiff
This commit is contained in:
@@ -2,7 +2,6 @@ package emu.nebula.server.routes;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import emu.nebula.GameConstants;
|
||||
import emu.nebula.proto.Pb.ServerAgent;
|
||||
import emu.nebula.proto.Pb.ServerListMeta;
|
||||
import emu.nebula.server.HttpServer;
|
||||
@@ -24,7 +23,7 @@ public class MetaServerlistHandler implements Handler {
|
||||
|
||||
// Create server list
|
||||
this.list = ServerListMeta.newInstance()
|
||||
.setVersion(GameConstants.DATA_VERSION)
|
||||
.setVersion(server.getDataVersion())
|
||||
.setReportEndpoint(server.getServerConfig().getDisplayAddress() + "/report");
|
||||
|
||||
var agent = ServerAgent.newInstance()
|
||||
|
||||
@@ -2,8 +2,9 @@ package emu.nebula.server.routes;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import emu.nebula.proto.Pb.ClientDiff;
|
||||
import emu.nebula.server.HttpServer;
|
||||
import emu.nebula.util.AeadHelper;
|
||||
import emu.nebula.util.Utils;
|
||||
import io.javalin.http.ContentType;
|
||||
import io.javalin.http.Context;
|
||||
import io.javalin.http.Handler;
|
||||
@@ -12,24 +13,27 @@ import lombok.Getter;
|
||||
|
||||
@Getter(AccessLevel.PRIVATE)
|
||||
public class MetaWinHandler implements Handler {
|
||||
private ClientDiff list;
|
||||
private byte[] proto;
|
||||
|
||||
public MetaWinHandler() {
|
||||
// Create client diff
|
||||
this.list = ClientDiff.newInstance();
|
||||
|
||||
// TODO load from json or something
|
||||
|
||||
// Cache proto
|
||||
this.proto = list.toByteArray();
|
||||
private HttpServer server;
|
||||
|
||||
public MetaWinHandler(HttpServer server) {
|
||||
this.server = server;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(@NotNull Context ctx) throws Exception {
|
||||
// Result
|
||||
// Get diff
|
||||
var diffBytes = this.getServer().getDiff();
|
||||
|
||||
// Sanity check
|
||||
if (diffBytes == null) {
|
||||
ctx.contentType(ContentType.APPLICATION_OCTET_STREAM);
|
||||
ctx.result(Utils.EMPTY_BYTE_ARRAY);
|
||||
return;
|
||||
}
|
||||
|
||||
// Encrypt patch list
|
||||
ctx.contentType(ContentType.APPLICATION_OCTET_STREAM);
|
||||
ctx.result(AeadHelper.encryptCBC(this.getProto()));
|
||||
ctx.result(AeadHelper.encryptCBC(diffBytes));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user