mirror of
https://github.com/CivMC/Civ.git
synced 2026-07-18 00:20:44 +00:00
update proxy rabbit
This commit is contained in:
@@ -131,7 +131,6 @@ services:
|
||||
- /opt/PrivateConfig/paper/plugins/packetevents-spigot-2.9.4.jar:/config/plugins/packetevents-spgiot-2.9.4.jar
|
||||
- /opt/PrivateConfig/paper/config/Vulcan/config.yml:/config/plugins/Vulcan/config.yml
|
||||
- /opt/PrivateConfig/paper/config/HiddenOre/config.yml:/config/plugins/HiddenOre/config.yml
|
||||
- /opt/PrivateConfig/paper/config/KiraBukkitGateway/config.yml:/config/plugins/KirraBukkitGateway/config.yml
|
||||
- /opt/PrivateConfig/paper/config/BreweryX/config.yml:/config/plugins/BreweryX/config.yml
|
||||
- /opt/PrivateConfig/paper/config/BreweryX/cauldron.yml:/config/plugins/BreweryX/cauldron.yml
|
||||
- /opt/PrivateConfig/paper/config/BreweryX/custom-items.yml:/config/plugins/BreweryX/custom-items.yml
|
||||
|
||||
@@ -27,6 +27,8 @@ import net.civmc.kiragatewayvelocity.rabbit.RabbitHandler;
|
||||
)
|
||||
public class KiraGateway {
|
||||
|
||||
public static final String PROXY_SERVER_NAME = "proxy";
|
||||
|
||||
private final ProxyServer proxy;
|
||||
public final Logger logger;
|
||||
public final Path dataDirectory;
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.civmc.kiragatewayvelocity.rabbit;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonObject;
|
||||
import java.util.UUID;
|
||||
import net.civmc.kiragatewayvelocity.KiraGateway;
|
||||
import net.civmc.kiragatewayvelocity.KiraUtil;
|
||||
|
||||
public class RabbitCommands {
|
||||
@@ -23,7 +24,7 @@ public class RabbitCommands {
|
||||
}
|
||||
|
||||
private void sendInternal(String id, JsonObject json) {
|
||||
json.addProperty("server", "proxy");
|
||||
json.addProperty("server", KiraGateway.PROXY_SERVER_NAME);
|
||||
json.addProperty("timestamp", System.currentTimeMillis());
|
||||
json.addProperty("packettype", id);
|
||||
Gson gson = new Gson();
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.rabbitmq.client.ConnectionFactory;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import com.rabbitmq.client.DeliverCallback;
|
||||
import net.civmc.kiragatewayvelocity.KiraGateway;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
public class RabbitHandler {
|
||||
@@ -42,23 +43,25 @@ public class RabbitHandler {
|
||||
}
|
||||
|
||||
public void beginAsyncListen() {
|
||||
DeliverCallback deliverCallback = (consumerTag, delivery) -> {
|
||||
KiraGateway.getInstance().getProxy().getScheduler().buildTask(KiraGateway.getInstance(), () -> {
|
||||
DeliverCallback deliverCallback = (consumerTag, delivery) -> {
|
||||
try {
|
||||
String message = new String(delivery.getBody(), "UTF-8");
|
||||
logger.info(" [x] Received '" + message + "'");
|
||||
inputProcessor.handle(message);
|
||||
} catch (Exception e) {
|
||||
logger.error("Exception in rabbit handling", e);
|
||||
}
|
||||
};
|
||||
try {
|
||||
String message = new String(delivery.getBody(), "UTF-8");
|
||||
logger.info(" [x] Received '" + message + "'");
|
||||
inputProcessor.handle(message);
|
||||
} catch (Exception e) {
|
||||
logger.error("Exception in rabbit handling", e);
|
||||
String queue = incomingChannel.queueDeclare().getQueue();
|
||||
incomingChannel.queueBind(queue, incomingQueue, KiraGateway.PROXY_SERVER_NAME);
|
||||
incomingChannel.basicConsume(queue, true, deliverCallback, consumerTag -> {
|
||||
});
|
||||
} catch (IOException e) {
|
||||
logger.error("Error in rabbit listener", e);
|
||||
}
|
||||
};
|
||||
try {
|
||||
String queue = incomingChannel.queueDeclare().getQueue();
|
||||
incomingChannel.queueBind(queue, incomingQueue, "proxy");
|
||||
incomingChannel.basicConsume(queue, true, deliverCallback, consumerTag -> {
|
||||
});
|
||||
} catch (IOException e) {
|
||||
logger.error("Error in rabbit listener", e);
|
||||
}
|
||||
}).schedule();
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
|
||||
Reference in New Issue
Block a user