コード例 #1
0
 @Override
 public final void handleUpstream(ChannelHandlerContext ctx, ChannelEvent e) throws Exception {
   if (e instanceof MessageEvent && ((MessageEvent) e).getMessage() instanceof Message) {
     Message buffer = (Message) ((MessageEvent) e).getMessage();
     BandwidthMonitor.bytesReceived.addAndGet(buffer.getBuffer().readableBytes());
   }
   super.handleUpstream(ctx, e);
 }
コード例 #2
0
 @Override
 public void handlePacket(Message m, GameSession gs) {
   Player p = gs.getPlayer();
   int size = m.getLength();
   if (m.getOpcode() == 119) {
     size -= 14;
   }
   if (m.getOpcode() != 138) {
     gs.getPlayer().setDistancedTask(null);
   }
   gs.getPlayer().getMovement().reset();
   int steps = (size - 5) / 2;
   int[] pathX = new int[steps];
   int[] pathY = new int[steps];
   // writeWordBigEndianA = writeLEShortA
   int firstX = m.readLEShortA() - (gs.getPlayer().getLocation().getRegionX() - 6) * 8;
   int firstY = m.readShortA() - (gs.getPlayer().getLocation().getRegionY() - 6) * 8;
   m.readByteC();
   for (int i = 0; i < steps; i++) {
     pathX[i] = m.readByte();
     pathY[i] = m.readByteS();
   }
   p.getMovement().addToWalkingQueue(firstX, firstY);
   for (int i = 0; i < steps; i++) {
     pathX[i] += firstX;
     pathY[i] += firstY;
     p.getMovement().addToWalkingQueue(pathX[i], pathY[i]);
   }
 }