Search in sources :

Example 11 with Wrapper

use of de.dytanic.cloudnetcore.network.components.Wrapper in project CloudNet by Dytanic.

the class PacketInAddCloudServer method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    if (!(packetSender instanceof Wrapper))
        return;
    Wrapper cn = ((Wrapper) packetSender);
    ServerInfo nullServerInfo = data.getObject("serverInfo", new TypeToken<ServerInfo>() {
    }.getType());
    CloudServerMeta serverProcessMeta = data.getObject("cloudServerMeta", new TypeToken<CloudServerMeta>() {
    }.getType());
    CloudServer minecraftServer = new CloudServer(cn, nullServerInfo, serverProcessMeta);
    cn.getCloudServers().put(nullServerInfo.getServiceId().getServerId(), minecraftServer);
    cn.getWaitingServices().remove(minecraftServer.getServerId());
    {
        if (serverProcessMeta.isPriorityStop()) {
            ServerGroup serverGroup = CloudNet.getInstance().getServerGroups().get(serverProcessMeta.getServiceId().getGroup());
            if (serverGroup != null) {
                PriorityStopTask priorityStopTask = new PriorityStopTask(cn, minecraftServer, serverGroup.getPriorityService().getStopTimeInSeconds());
                ScheduledTask scheduledTask = CloudNet.getInstance().getSubScheduler().runTaskRepeatSync(priorityStopTask, 0, 50);
                priorityStopTask.setScheduledTask(scheduledTask);
            }
        }
    }
    CloudNet.getInstance().getNetworkManager().handleServerAdd(minecraftServer);
}
Also used : CloudServerMeta(de.dytanic.cloudnet.lib.cloudserver.CloudServerMeta) PriorityStopTask(de.dytanic.cloudnetcore.network.components.priority.PriorityStopTask) Wrapper(de.dytanic.cloudnetcore.network.components.Wrapper) ServerGroup(de.dytanic.cloudnet.lib.server.ServerGroup) ServerInfo(de.dytanic.cloudnet.lib.server.info.ServerInfo) TypeToken(com.google.gson.reflect.TypeToken) CloudServer(de.dytanic.cloudnetcore.network.components.CloudServer) ScheduledTask(de.dytanic.cloudnet.lib.utility.threading.ScheduledTask)

Example 12 with Wrapper

use of de.dytanic.cloudnetcore.network.components.Wrapper in project CloudNet by Dytanic.

the class PacketInAddProxy method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    if (!(packetSender instanceof Wrapper))
        return;
    Wrapper cn = ((Wrapper) packetSender);
    ProxyInfo nullServerInfo = data.getObject("proxyInfo", new TypeToken<ProxyInfo>() {
    }.getType());
    ProxyProcessMeta proxyProcessMeta = data.getObject("proxyProcess", new TypeToken<ProxyProcessMeta>() {
    }.getType());
    ProxyServer minecraftServer = new ProxyServer(proxyProcessMeta, cn, nullServerInfo);
    cn.getProxys().put(proxyProcessMeta.getServiceId().getServerId(), minecraftServer);
    cn.getWaitingServices().remove(minecraftServer.getServerId());
    CloudNet.getInstance().getNetworkManager().handleProxyAdd(minecraftServer);
}
Also used : Wrapper(de.dytanic.cloudnetcore.network.components.Wrapper) ProxyInfo(de.dytanic.cloudnet.lib.server.info.ProxyInfo) TypeToken(com.google.gson.reflect.TypeToken) ProxyProcessMeta(de.dytanic.cloudnet.lib.server.ProxyProcessMeta) ProxyServer(de.dytanic.cloudnetcore.network.components.ProxyServer)

Example 13 with Wrapper

use of de.dytanic.cloudnetcore.network.components.Wrapper in project CloudNet by Dytanic.

the class PacketInAddServer method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    if (!(packetSender instanceof Wrapper))
        return;
    Wrapper cn = ((Wrapper) packetSender);
    ServerInfo nullServerInfo = data.getObject("serverInfo", new TypeToken<ServerInfo>() {
    }.getType());
    ServerProcessMeta serverProcessMeta = data.getObject("serverProcess", new TypeToken<ServerProcessMeta>() {
    }.getType());
    MinecraftServer minecraftServer = new MinecraftServer(serverProcessMeta, cn, CloudNet.getInstance().getServerGroups().get(nullServerInfo.getServiceId().getGroup()), nullServerInfo);
    cn.getServers().put(nullServerInfo.getServiceId().getServerId(), minecraftServer);
    cn.getWaitingServices().remove(minecraftServer.getServerId());
    {
        if (serverProcessMeta.isPriorityStop()) {
            ServerGroup serverGroup = CloudNet.getInstance().getServerGroups().get(serverProcessMeta.getServiceId().getGroup());
            if (serverGroup != null) {
                PriorityStopTask priorityStopTask = new PriorityStopTask(cn, minecraftServer, serverGroup.getPriorityService().getStopTimeInSeconds());
                ScheduledTask scheduledTask = CloudNet.getInstance().getSubScheduler().runTaskRepeatSync(priorityStopTask, 0, 50);
                priorityStopTask.setScheduledTask(scheduledTask);
            }
        }
    }
    CloudNet.getInstance().getNetworkManager().handleServerAdd(minecraftServer);
}
Also used : PriorityStopTask(de.dytanic.cloudnetcore.network.components.priority.PriorityStopTask) Wrapper(de.dytanic.cloudnetcore.network.components.Wrapper) ServerGroup(de.dytanic.cloudnet.lib.server.ServerGroup) ServerProcessMeta(de.dytanic.cloudnet.lib.server.ServerProcessMeta) ServerInfo(de.dytanic.cloudnet.lib.server.info.ServerInfo) TypeToken(com.google.gson.reflect.TypeToken) ScheduledTask(de.dytanic.cloudnet.lib.utility.threading.ScheduledTask) MinecraftServer(de.dytanic.cloudnetcore.network.components.MinecraftServer)

Example 14 with Wrapper

use of de.dytanic.cloudnetcore.network.components.Wrapper in project CloudNet by Dytanic.

the class PacketInEnableScreen method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    if (!(packetSender instanceof Wrapper))
        return;
    ServiceId serviceId = data.getObject("serviceId", new TypeToken<ServiceId>() {
    }.getType());
    CloudNet.getInstance().getScreenProvider().handleEnableScreen(serviceId, ((Wrapper) packetSender));
}
Also used : Wrapper(de.dytanic.cloudnetcore.network.components.Wrapper) TypeToken(com.google.gson.reflect.TypeToken) ServiceId(de.dytanic.cloudnet.lib.service.ServiceId)

Example 15 with Wrapper

use of de.dytanic.cloudnetcore.network.components.Wrapper in project CloudNet by Dytanic.

the class PacketInRemoveCloudServer method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    if (!(packetSender instanceof Wrapper))
        return;
    Wrapper cn = (Wrapper) packetSender;
    ServerInfo serverInfo = data.getObject("serverInfo", new TypeToken<ServerInfo>() {
    }.getType());
    if (cn.getServers().containsKey(serverInfo.getServiceId().getServerId())) {
        CloudServer minecraftServer = cn.getCloudServers().get(serverInfo.getServiceId().getServerId());
        if (minecraftServer.getChannel() != null) {
            minecraftServer.getChannel().close().syncUninterruptibly();
        }
        cn.getCloudServers().remove(serverInfo.getServiceId().getServerId());
        CloudNet.getInstance().getNetworkManager().handleServerRemove(minecraftServer);
    }
}
Also used : Wrapper(de.dytanic.cloudnetcore.network.components.Wrapper) ServerInfo(de.dytanic.cloudnet.lib.server.info.ServerInfo) TypeToken(com.google.gson.reflect.TypeToken) CloudServer(de.dytanic.cloudnetcore.network.components.CloudServer)

Aggregations

Wrapper (de.dytanic.cloudnetcore.network.components.Wrapper)23 TypeToken (com.google.gson.reflect.TypeToken)11 MinecraftServer (de.dytanic.cloudnetcore.network.components.MinecraftServer)9 ProxyServer (de.dytanic.cloudnetcore.network.components.ProxyServer)9 ServerGroup (de.dytanic.cloudnet.lib.server.ServerGroup)5 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)5 ProxyGroup (de.dytanic.cloudnet.lib.server.ProxyGroup)4 CloudServer (de.dytanic.cloudnetcore.network.components.CloudServer)4 ServiceId (de.dytanic.cloudnet.lib.service.ServiceId)3 ProxyInfo (de.dytanic.cloudnet.lib.server.info.ProxyInfo)2 CollectionWrapper (de.dytanic.cloudnet.lib.utility.CollectionWrapper)2 MapWrapper (de.dytanic.cloudnet.lib.utility.MapWrapper)2 ScheduledTask (de.dytanic.cloudnet.lib.utility.threading.ScheduledTask)2 PriorityStopTask (de.dytanic.cloudnetcore.network.components.priority.PriorityStopTask)2 CloudFlareService (de.dytanic.cloudnet.cloudflare.CloudFlareService)1 CloudFlareDatabase (de.dytanic.cloudnet.cloudflare.database.CloudFlareDatabase)1 CloudServerMeta (de.dytanic.cloudnet.lib.cloudserver.CloudServerMeta)1 WrapperInfo (de.dytanic.cloudnet.lib.network.WrapperInfo)1 AuthLoginResult (de.dytanic.cloudnet.lib.network.auth.AuthLoginResult)1 PacketOutAuthResult (de.dytanic.cloudnet.lib.network.auth.packetio.PacketOutAuthResult)1