Class PacketInterceptor


  • @Singleton
    public class PacketInterceptor
    extends java.lang.Object
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  PacketInterceptor.PacketHookAdvice
      The Advice class injected directly into "addNode".
    • Constructor Summary

      Constructors 
      Constructor Description
      PacketInterceptor​(net.runelite.api.Client client)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static EncodedPacket analyzePacket​(java.lang.Object packetBufferNode)
      Extracts the encrypted Packet id (not opcode), size, and byte array payload from the PacketBufferNode.
      void injectHook()
      Modifies the bytecode of the "addNode" method within the client at runtime to invoke the PacketInterceptor.PacketHookAdvice class whenever the method is called.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • eventBus

        public static final net.runelite.client.eventbus.EventBus eventBus
      • injected

        public boolean injected
      • client

        public net.runelite.api.Client client
    • Constructor Detail

      • PacketInterceptor

        @Inject
        public PacketInterceptor​(net.runelite.api.Client client)
    • Method Detail

      • injectHook

        public void injectHook()
                        throws java.lang.Exception
        Modifies the bytecode of the "addNode" method within the client at runtime to invoke the PacketInterceptor.PacketHookAdvice class whenever the method is called. This will publish the PacketSent event to the eventbus which can be Subscribe to within plugins who need access to low level packets.
        Throws:
        java.lang.Exception - Throws an Illegal state exception if the hook is not able to be injected.
      • analyzePacket

        public static EncodedPacket analyzePacket​(java.lang.Object packetBufferNode)
        Extracts the encrypted Packet id (not opcode), size, and byte array payload from the PacketBufferNode.
        Parameters:
        packetBufferNode - The packet buffer node object.
        Returns:
        EncodedPacket The encoded packet, containing the id (not opcode), size, and byte array payload.