public void processIncomingPackets() { for (LSPacket p : packetQueue.getPackets()) { PacketHandler handler; if (((handler = uniqueHandlers.get(p.getUID())) != null) || ((handler = packetHandlers.get(p.getID())) != null)) { try { handler.handlePacket(p, session); uniqueHandlers.remove(p.getUID()); } catch (Exception e) { Logger.error("Exception with p[" + p.getID() + "] from LOGIN_SERVER: " + e.getMessage()); } } else { Logger.error("Unhandled packet from LS: " + p.getID()); } } }
public void setRegistered(boolean registered) { if (registered) { this.registered = true; Logger.print("World successfully registered with LS"); } else { Logger.error(new Exception("Error registering world")); } }
private void loadPacketHandlers() { PacketHandlerDef[] handlerDefs = (PacketHandlerDef[]) PersistenceManager.load("LSPacketHandlers.xml"); for (PacketHandlerDef handlerDef : handlerDefs) { try { String className = handlerDef.getClassName(); Class c = Class.forName(className); if (c != null) { PacketHandler handler = (PacketHandler) c.newInstance(); for (int packetID : handlerDef.getAssociatedPackets()) { packetHandlers.put(packetID, handler); } } } catch (Exception e) { Logger.error(e); } } }