Esempio n. 1
0
  /**
   * Encodes a packet encoder state into a buffer.
   *
   * @param state The packet encoder state to encode.
   * @return The encoded buffer.
   */
  public ByteBuffer encode(PacketEncoderState state) {

    /* Check if the encoder map contains a value for the specified packet */
    String packetName = state.getPacket().getName();
    if (!encoders.containsKey(packetName)) {
      return null;
    }

    /* Encode the packet encoder state into a buffer */
    PacketEncoder encoder = encoders.get(packetName);
    return encoder.encode(state);
  }
Esempio n. 2
0
 /**
  * Register a packet encoder.
  *
  * @param encoder The packet encoder to register.
  */
 public void register(PacketEncoder encoder) {
   encoders.put(encoder.getPacketName(), encoder);
 }