Search in sources :

Example 6 with CloudServer

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

the class PacketInCustomSubChannelMessage method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    DefaultType defaultType = data.getObject("defaultType", DefaultType.class);
    String channel = data.getString("channel");
    String message = data.getString("message");
    Document document = data.getDocument("value");
    if (defaultType.equals(DefaultType.BUKKIT)) {
        if (data.contains("serverId")) {
            MinecraftServer minecraftServer = CloudNet.getInstance().getServer(data.getString("serverId"));
            if (minecraftServer != null) {
                minecraftServer.sendPacket(new PacketOutCustomSubChannelMessage(channel, message, document));
                return;
            }
            CloudServer cloudServer = CloudNet.getInstance().getCloudGameServer(data.getString("serverId"));
            if (cloudServer != null) {
                cloudServer.sendPacket(new PacketOutCustomSubChannelMessage(channel, message, document));
            }
        } else {
            CloudNet.getInstance().getNetworkManager().sendAll(new PacketOutCustomSubChannelMessage(channel, message, document), new ChannelFilter() {

                @Override
                public boolean accept(INetworkComponent networkComponent) {
                    return networkComponent instanceof MinecraftServer || networkComponent instanceof CloudServer;
                }
            });
        }
    } else {
        if (data.contains("serverId")) {
            ProxyServer proxyServer = CloudNet.getInstance().getProxy(data.getString("serverId"));
            if (proxyServer != null) {
                proxyServer.sendPacket(new PacketOutCustomSubChannelMessage(channel, message, document));
            }
        } else {
            CloudNet.getInstance().getNetworkManager().sendToProxy(new PacketOutCustomSubChannelMessage(channel, message, document));
        }
    }
}
Also used : ChannelFilter(de.dytanic.cloudnetcore.network.components.util.ChannelFilter) PacketOutCustomSubChannelMessage(de.dytanic.cloudnetcore.network.packet.out.PacketOutCustomSubChannelMessage) INetworkComponent(de.dytanic.cloudnetcore.network.components.INetworkComponent) DefaultType(de.dytanic.cloudnet.lib.DefaultType) CloudServer(de.dytanic.cloudnetcore.network.components.CloudServer) Document(de.dytanic.cloudnet.lib.utility.document.Document) MinecraftServer(de.dytanic.cloudnetcore.network.components.MinecraftServer) ProxyServer(de.dytanic.cloudnetcore.network.components.ProxyServer)

Example 7 with CloudServer

use of de.dytanic.cloudnetcore.network.components.CloudServer 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

CloudServer (de.dytanic.cloudnetcore.network.components.CloudServer)7 MinecraftServer (de.dytanic.cloudnetcore.network.components.MinecraftServer)5 ProxyServer (de.dytanic.cloudnetcore.network.components.ProxyServer)4 Wrapper (de.dytanic.cloudnetcore.network.components.Wrapper)4 TypeToken (com.google.gson.reflect.TypeToken)3 DefaultType (de.dytanic.cloudnet.lib.DefaultType)2 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)2 CloudServerMeta (de.dytanic.cloudnet.lib.cloudserver.CloudServerMeta)1 AuthLoginResult (de.dytanic.cloudnet.lib.network.auth.AuthLoginResult)1 PacketOutAuthResult (de.dytanic.cloudnet.lib.network.auth.packetio.PacketOutAuthResult)1 ServerGroup (de.dytanic.cloudnet.lib.server.ServerGroup)1 ServiceId (de.dytanic.cloudnet.lib.service.ServiceId)1 CollectionWrapper (de.dytanic.cloudnet.lib.utility.CollectionWrapper)1 Document (de.dytanic.cloudnet.lib.utility.document.Document)1 ScheduledTask (de.dytanic.cloudnet.lib.utility.threading.ScheduledTask)1 CloudNetClient (de.dytanic.cloudnetcore.network.CloudNetClient)1 CloudNetClientAuth (de.dytanic.cloudnetcore.network.CloudNetClientAuth)1 INetworkComponent (de.dytanic.cloudnetcore.network.components.INetworkComponent)1 PriorityStopTask (de.dytanic.cloudnetcore.network.components.priority.PriorityStopTask)1 ChannelFilter (de.dytanic.cloudnetcore.network.components.util.ChannelFilter)1