Ejemplo n.º 1
0
  /**
   * Decodes a packet decoder state into a packet.
   *
   * @param state The packet encoder state to encode.
   * @return The encoded buffer.
   */
  public Packet decode(PacketDecoderState state) {

    /* Check if the decoder map contains a value for the specified decoder */
    int decoderId = state.getDecoderId();
    if (!decoders.containsKey(decoderId)) {
      return null;
    }

    /* Encode the packet decoder state into a packet */
    PacketDecoder encoder = decoders.get(decoderId);
    return encoder.decode(state);
  }
Ejemplo n.º 2
0
 /**
  * Register a packet encoder.
  *
  * @param decoder The packet decoder to register.
  */
 public void register(PacketDecoder decoder) {
   decoders.put(decoder.getId(), decoder);
 }