Interface PacketHandler<T>

Type Parameters:
T - The POJO that maps to the given packet.
All Known Implementing Classes:
AccountInfoRequestHandler, AccountInfoResponseHandler, AccountListHandler, AccountReg2RequestHandler, AccountReg2ResponseHandler, AccountReg2StoreRequestHandler, AuthorizeUserHandler, AuthorizeUserResponseHandler, AuthRequestHandler, AuthResponseHandler, LoginFailedHandler, LoginRequestHandler, LoginSuccessHandler2016, LoginSuccessHandler20170315, LoginSuccessHandlerBase, PingHandler, PingPacketHandler, PongHandler, PongPacketHandler, SetAccountOfflineHandler, SetAccountOnlineHandler, SetAllAccountsOfflineHandler, UserCountHandler

public interface PacketHandler<T>
Interface responsible for converting to and from Packet objects to a POJO type
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    Convert the given buffer to the type.
     
    void
    toPacket(Context ctx, io.netty.buffer.ByteBuf buffer, T src)
    Writes the object of type T to the byte buffer.
    static void
    writeStr(io.netty.buffer.ByteBuf buf, String str, int len)
    Writes the string to the given byte buffer, padding the given 0 bytes based on the length.
  • Method Details

    • fromPacket

      T fromPacket(Context ctx, PacketReader reader) throws Exception
      Convert the given buffer to the type.
      Parameters:
      ctx - The calling context.
      reader - The input buffer stream reader.
      Returns:
      The POJO object
      Throws:
      Exception - on errors
    • toPacket

      void toPacket(Context ctx, io.netty.buffer.ByteBuf buffer, T src) throws Exception
      Writes the object of type T to the byte buffer.
      Parameters:
      ctx - The calling context.
      buffer - The destination buffer.
      src - The source object we are converting.
      Throws:
      Exception - on errors
    • rule

      PacketRule rule(Context ctx)
      Parameters:
      ctx - The calling context.
      Returns:
      The packet rule object which specifies when this packet handler should be called.
      See Also:
    • writeStr

      static void writeStr(io.netty.buffer.ByteBuf buf, String str, int len)
      Writes the string to the given byte buffer, padding the given 0 bytes based on the length.
      Parameters:
      buf - The buffer to write to.
      str - The string to write.
      len - The length of the string in the byte stream.