use of io.xol.chunkstories.api.net.PacketWorldStreaming in project chunkstories by Hugobros3.
the class TCPServerConnection method handleDatagram.
@Override
public void handleDatagram(LogicalPacketDatagram datagram) throws IOException, PacketProcessingException, IllegalPacketException {
// (PacketDefinitionImpl) getPacketsContext().getContentTranslator().getPacketForId(datagram.packetTypeId);
PacketDefinitionImplementation definition = (PacketDefinitionImplementation) datagram.packetDefinition;
if (definition.getGenre() == PacketGenre.GENERAL_PURPOSE) {
Packet packet = definition.createNew(true, null);
packet.process(getRemoteServer(), datagram.getData(), getPacketsContext());
datagram.dispose();
} else if (definition.getGenre() == PacketGenre.SYSTEM) {
Packet packet = definition.createNew(true, null);
packet.process(getRemoteServer(), datagram.getData(), getPacketsContext());
if (packet instanceof PacketText) {
handleSystemRequest(((PacketText) packet).text);
}
datagram.dispose();
} else if (definition.getGenre() == PacketGenre.WORLD) {
WorldClientRemote world = getPacketsContext().getWorld();
world.queueDatagram(datagram);
} else if (definition.getGenre() == PacketGenre.WORLD_STREAMING) {
WorldClientRemote world = getPacketsContext().getWorld();
PacketWorldStreaming packet = (PacketWorldStreaming) definition.createNew(true, world);
packet.process(getRemoteServer(), datagram.getData(), getPacketsContext());
world.ioHandler().handlePacketWorldStreaming(packet);
datagram.dispose();
} else {
throw new RuntimeException("whut");
}
}
use of io.xol.chunkstories.api.net.PacketWorldStreaming in project chunkstories by Hugobros3.
the class SocketedClientConnection method handleDatagram.
@Override
public void handleDatagram(LogicalPacketDatagram datagram) throws IOException, PacketProcessingException, IllegalPacketException {
// getPacketsContext().getContentTranslator().getPacketForId(datagram.packetTypeId);
PacketDefinitionImplementation definition = (PacketDefinitionImplementation) datagram.packetDefinition;
if (definition.getGenre() == PacketGenre.GENERAL_PURPOSE) {
Packet packet = definition.createNew(true, null);
packet.process(packetsProcessor.getInterlocutor(), datagram.getData(), getPacketsContext());
datagram.dispose();
} else if (definition.getGenre() == PacketGenre.SYSTEM) {
Packet packet = definition.createNew(true, null);
packet.process(packetsProcessor.getInterlocutor(), datagram.getData(), getPacketsContext());
if (packet instanceof PacketText) {
handleSystemRequest(((PacketText) packet).text);
}
datagram.dispose();
} else if (definition.getGenre() == PacketGenre.WORLD) {
// Queue packets for a specific world
if (player != null) {
WorldServer world = player.getWorld();
if (world != null) {
world.queueDatagram(datagram, player);
}
}
} else if (definition.getGenre() == PacketGenre.WORLD_STREAMING) {
// Server doesn't expect world streaming updates from the client
// it does, however, listen to world_user_requests packets to keep
// track of the client's world data
WorldServer world = getPacketsContext().getWorld();
PacketWorldStreaming packet = (PacketWorldStreaming) definition.createNew(false, world);
packet.process(packetsProcessor.getInterlocutor(), datagram.getData(), getPacketsContext());
datagram.dispose();
} else {
throw new RuntimeException("whut");
}
}
Aggregations