use of de.dytanic.cloudnet.lib.network.NetDispatcher in project CloudNet by Dytanic.
the class CloudAPI method bootstrap.
/*================= Internal =====================*/
@Deprecated
public void bootstrap() {
this.networkConnection.tryConnect(config.getBoolean("ssl"), new NetDispatcher(networkConnection, false), new Auth(serviceId), shutdownTask);
NetworkUtils.header();
}
use of de.dytanic.cloudnet.lib.network.NetDispatcher in project CloudNet by Dytanic.
the class CloudNetWrapper method onShutdownCentral.
@Override
public void onShutdownCentral() throws Exception {
canDeployed = false;
if (serverProcessQueue != null) {
serverProcessQueue.getProxys().clear();
serverProcessQueue.getServers().clear();
serverProcessQueue.setRunning(false);
}
for (GameServer gameServer : servers.values()) gameServer.shutdown();
for (BungeeCord gameServer : proxys.values()) gameServer.shutdown();
proxyGroups.clear();
serverGroups.clear();
System.out.println("Wrapper try to connect to the CloudNet-Core");
try {
FileUtils.deleteDirectory(new File("temp"));
} catch (Exception ex) {
}
new File("temp").mkdir();
while (networkConnection.getChannel() == null) {
networkConnection.tryConnect(optionSet.has("ssl"), new NetDispatcher(networkConnection, false), auth);
if (networkConnection.getChannel() != null) {
networkConnection.sendPacketSynchronized(new PacketOutUpdateWrapperInfo());
break;
}
Thread.sleep(2000);
}
canDeployed = true;
if (serverProcessQueue != null)
serverProcessQueue.setRunning(true);
}
use of de.dytanic.cloudnet.lib.network.NetDispatcher in project CloudNet by Dytanic.
the class CloudNetWrapper method bootstrap.
@Override
public boolean bootstrap() throws Exception {
if (!optionSet.has("disable-autoupdate"))
checkForUpdates();
if (!optionSet.has("disallow_bukkit_download") && !Files.exists(Paths.get("local/spigot.jar")))
new SetupSpigotVersion().run(cloudNetLogging.getReader());
Thread thread = new Thread(scheduler);
thread.setDaemon(true);
thread.start();
commandManager.registerCommand(new CommandHelp()).registerCommand(new CommandClear()).registerCommand(new CommandVersion()).registerCommand(new CommandClearCache()).registerCommand(new CommandStop()).registerCommand(new CommandReload());
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE, PacketInWrapperInfo.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 1, PacketInStartProxy.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 2, PacketInStopProxy.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 3, PacketInStartServer.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 4, PacketInStopServer.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 5, PacketInCreateTemplate.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 6, PacketInScreen.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 7, PacketInExecuteServerCommand.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 8, PacketInInstallUpdate.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 9, PacketInExecuteCommand.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 10, PacketInCopyServer.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 11, PacketInOnlineServer.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 12, PacketInUpdateWrapperProperties.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 13, PacketInStartCloudServer.class);
networkConnection.getPacketManager().registerHandler(PacketRC.CN_CORE + 14, PacketInCopyDirectory.class);
networkConnection.getPacketManager().registerHandler(PacketRC.TEST + 1, PacketInTestResult.class);
System.out.println("Trying to connect " + networkConnection.getConnectableAddress().getHostName() + ":" + networkConnection.getConnectableAddress().getPort());
while (networkConnection.getConnectionTrys() < 5 && networkConnection.getChannel() == null) {
networkConnection.tryConnect(optionSet.has("ssl"), new NetDispatcher(networkConnection, false), auth);
if (networkConnection.getChannel() != null) {
networkConnection.sendPacketSynchronized(new PacketOutUpdateWrapperInfo());
break;
}
Thread.sleep(2000);
if (networkConnection.getConnectionTrys() == 5)
System.exit(0);
}
if (!Files.exists(Paths.get("local/server-icon.png")))
FileCopy.insertData("files/server-icon.png", "local/server-icon.png");
System.out.println("Starting process queue...");
scheduler.runTaskRepeatSync(serverProcessQueue, 0, 20);
// Server Handlers
{
networkConnection.sendPacket(new PacketOutSetReadyWrapper(true));
IWrapperHandler iWrapperHandler = new StopTimeHandler();
scheduler.runTaskRepeatSync(iWrapperHandler.toExecutor(), 0, iWrapperHandler.getTicks());
scheduler.runTaskRepeatSync(new Runnable() {
@Override
public void run() {
networkConnection.sendPacket(new PacketOutUpdateCPUUsage(getCpuUsage()));
}
}, 0, 200);
}
cloudNetLogging.getHandler().add(new ICloudLoggerHandler() {
@Override
public void handleConsole(String input) {
if (networkConnection.isConnected())
networkConnection.sendPacket(new PacketOutWrapperScreen(input));
}
});
canDeployed = true;
RUNNING = true;
Runtime.getRuntime().addShutdownHook(new Thread(this));
return true;
}
Aggregations