use of de.dytanic.cloudnetcore.network.components.Wrapper in project CloudNet by Dytanic.
the class PacketInUpdateProxyGroup method handleInput.
@Override
public void handleInput(Document data, PacketSender packetSender) {
ProxyGroup proxyGroup = data.getObject("group", new TypeToken<ProxyGroup>() {
}.getType());
CloudNet.getInstance().getConfig().createGroup(proxyGroup);
try {
CloudNet.getInstance().getConfig().load();
} catch (Exception e) {
e.printStackTrace();
}
CloudNet.getInstance().getServerGroups().clear();
CloudNet.getInstance().getProxyGroups().clear();
NetworkUtils.addAll(CloudNet.getInstance().getServerGroups(), CloudNet.getInstance().getConfig().getServerGroups(), new Acceptable<ServerGroup>() {
@Override
public boolean isAccepted(ServerGroup value) {
System.out.println("Loading server group: " + value.getName());
return true;
}
});
NetworkUtils.addAll(CloudNet.getInstance().getProxyGroups(), CloudNet.getInstance().getConfig().getProxyGroups(), new Acceptable<ProxyGroup>() {
@Override
public boolean isAccepted(ProxyGroup value) {
System.out.println("Loading proxy group: " + value.getName());
return true;
}
});
CloudNet.getInstance().getNetworkManager().reload();
CloudNet.getInstance().getNetworkManager().updateAll0();
CloudNet.getInstance().getWrappers().values().forEach(new Consumer<Wrapper>() {
@Override
public void accept(Wrapper wrapper) {
wrapper.updateWrapper();
}
});
}
use of de.dytanic.cloudnetcore.network.components.Wrapper in project CloudNet by Dytanic.
the class CloudConfig method createWrapper.
public void createWrapper(WrapperMeta wrapperMeta) {
Collection<WrapperMeta> wrapperMetas = this.serviceDocument.getObject("wrapper", new TypeToken<Collection<WrapperMeta>>() {
}.getType());
WrapperMeta is = CollectionWrapper.filter(wrapperMetas, new Acceptable<WrapperMeta>() {
@Override
public boolean isAccepted(WrapperMeta wrapperMeta_) {
return wrapperMeta_.getId().equalsIgnoreCase(wrapperMeta.getId());
}
});
if (is != null)
wrapperMetas.remove(is);
wrapperMetas.add(wrapperMeta);
this.serviceDocument.append("wrapper", wrapperMetas).saveAsConfig(servicePath);
CloudNet.getInstance().getWrappers().put(wrapperMeta.getId(), new Wrapper(wrapperMeta));
}
use of de.dytanic.cloudnetcore.network.components.Wrapper in project CloudNet by Dytanic.
the class CloudFlareModule method onBootstrap.
@Override
public void onBootstrap() {
configCloudFlare = new ConfigCloudFlare();
cloudFlareDatabase = new CloudFlareDatabase(getCloud().getDatabaseManager().getDatabase("cloud_internal_cfg"));
try {
CloudFlareService cloudFlareAPI = new CloudFlareService(configCloudFlare.load());
cloudFlareAPI.bootstrap(MapWrapper.transform(getCloud().getWrappers(), new Catcher<String, String>() {
@Override
public String doCatch(String key) {
return key;
}
}, new Catcher<SimpledWrapperInfo, Wrapper>() {
@Override
public SimpledWrapperInfo doCatch(Wrapper key) {
return new SimpledWrapperInfo(key.getServerId(), key.getNetworkInfo().getHostName());
}
}), getCloud().getProxyGroups(), cloudFlareDatabase);
} catch (Exception ex) {
ex.printStackTrace();
}
getCloud().getEventManager().registerListener(this, new ProxyAddListener());
getCloud().getEventManager().registerListener(this, new ProxyRemoveListener());
}
Aggregations