Class Decoder

java.lang.Object
marauroa.common.net.Decoder

public class Decoder extends Object
This class decodes a stream of bytes and builds a Marauroa message with it. Decoder follows singleton pattern.
Author:
miguel, hendrik
  • Method Details

    • get

      public static Decoder get()
      Returns an unique instance of decoder
      Returns:
      an unique instance of decoder
    • clear

      public void clear(SocketChannel channel)
      Removes any pending data from a connection
      Parameters:
      channel - the channel to clear data from.
    • decode

      public List<Message> decode(Object channel, byte[] data) throws IOException, InvalidVersionException
      Decodes a message from a stream of bytes received from channel
      Parameters:
      channel - the socket from where data was received
      data - the data received
      Returns:
      a message or null if it was not possible
      Throws:
      IOException - if there is a problem building the message
      InvalidVersionException - if the message version mismatch the expected version