Search in sources :

Example 1 with Packet

use of de.dytanic.cloudnet.lib.network.protocol.packet.Packet in project CloudNet by Dytanic.

the class CloudNetClient method channelRead0.

@Override
protected void channelRead0(ChannelHandlerContext channelHandlerContext, Object obj) throws Exception {
    if (!(obj instanceof Packet))
        return;
    CloudNet.getLogger().debug("Receiving Packet on " + getChannel().remoteAddress().toString());
    Packet packet = (Packet) obj;
    CloudNet.getInstance().getPacketManager().dispatchPacket(packet, networkComponent);
}
Also used : Packet(de.dytanic.cloudnet.lib.network.protocol.packet.Packet)

Example 2 with Packet

use of de.dytanic.cloudnet.lib.network.protocol.packet.Packet in project CloudNet by Dytanic.

the class PacketInCopyDirectory method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    if (!data.contains("serverInfo") || !data.contains("directory"))
        return;
    ServerInfo info = data.getObject("serverInfo", ServerInfo.TYPE);
    Wrapper wrapper = CloudNet.getInstance().getWrappers().get(info.getServiceId().getWrapperId());
    if (wrapper != null && wrapper.getChannel() != null)
        wrapper.sendPacket(new Packet(PacketRC.CN_CORE + 14, data));
}
Also used : Wrapper(de.dytanic.cloudnetcore.network.components.Wrapper) Packet(de.dytanic.cloudnet.lib.network.protocol.packet.Packet) ServerInfo(de.dytanic.cloudnet.lib.server.info.ServerInfo)

Example 3 with Packet

use of de.dytanic.cloudnet.lib.network.protocol.packet.Packet in project CloudNet by Dytanic.

the class NetDispatcher method channelRead0.

@Override
protected void channelRead0(ChannelHandlerContext channelHandlerContext, Object o) throws Exception {
    if (o instanceof Packet) {
        TaskScheduler.runtimeScheduler().schedule(new Runnable() {

            @Override
            public void run() {
                networkConnection.getPacketManager().dispatchPacket(((Packet) o), networkConnection);
            }
        });
    } else {
        if (o instanceof FileDeploy) {
            FileDeploy deploy = ((FileDeploy) o);
            TaskScheduler.runtimeScheduler().schedule(new Runnable() {

                @Override
                public void run() {
                    deploy.toWrite();
                }
            });
        }
    }
}
Also used : Packet(de.dytanic.cloudnet.lib.network.protocol.packet.Packet) FileDeploy(de.dytanic.cloudnet.lib.network.protocol.file.FileDeploy)

Example 4 with Packet

use of de.dytanic.cloudnet.lib.network.protocol.packet.Packet in project CloudNet by Dytanic.

the class PacketAPIInGetPlayers method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    Packet packet = getResult(new Document().append("players", CloudNet.getInstance().getNetworkManager().getOnlinePlayers().values()));
    packetSender.sendPacket(packet);
}
Also used : Packet(de.dytanic.cloudnet.lib.network.protocol.packet.Packet) Document(de.dytanic.cloudnet.lib.utility.document.Document)

Example 5 with Packet

use of de.dytanic.cloudnet.lib.network.protocol.packet.Packet in project CloudNet by Dytanic.

the class PacketAPIInGetStatistic method handleInput.

@Override
public void handleInput(Document data, PacketSender packetSender) {
    Packet packet = getResult(StatisticManager.getInstance().getStatistics());
    packetSender.sendPacket(packet);
}
Also used : Packet(de.dytanic.cloudnet.lib.network.protocol.packet.Packet)

Aggregations

Packet (de.dytanic.cloudnet.lib.network.protocol.packet.Packet)5 FileDeploy (de.dytanic.cloudnet.lib.network.protocol.file.FileDeploy)1 ServerInfo (de.dytanic.cloudnet.lib.server.info.ServerInfo)1 Document (de.dytanic.cloudnet.lib.utility.document.Document)1 Wrapper (de.dytanic.cloudnetcore.network.components.Wrapper)1