/** * level comment: * * <p>1: info * * <p>2: debug * * <p>3: warn * * <p>4: error * * <p>5: fatal */ public void send(packet p, int level) { byte[] b = null; date.setTime(System.currentTimeMillis()); if (!isServer) { switch (level) { case 1: b = ArrayUtils.addAll( (DateFormat.format(date) + "[" + ip + "][" + className + "][info]").getBytes(), p.getArgs()); break; case 2: b = ArrayUtils.addAll( (DateFormat.format(date) + "[" + ip + "][" + className + "][debug]").getBytes(), p.getArgs()); break; case 3: b = ArrayUtils.addAll( (DateFormat.format(date) + "[" + ip + "][" + className + "][warn]").getBytes(), p.getArgs()); break; case 4: b = ArrayUtils.addAll( (DateFormat.format(date) + "[" + ip + "][" + className + "][error]").getBytes(), p.getArgs()); break; case 5: b = ArrayUtils.addAll( (DateFormat.format(date) + "[" + ip + "][" + className + "][fatal]").getBytes(), p.getArgs()); break; } } if (LOG != null) { LOG.info(new String(b)); } if (level > reportLevel) { client.addSendPacket(new packet(BasicMessage.NODE, BasicMessage.OP_MESSAGE, b)); } }
public packet receive() { if (server != null) return server.getNewSegement().p; else { return client.getReceivePacket(); } }