def parse_chunk(chunk)
      @buildup << chunk
      chunks = @buildup.split(CommandSerializer::SEPARATOR, -1)
      if (do_call = chunks.size > 1)
        commands = []
        (0..chunks.size - 2).each do |i|
          begin
            commands << CommandSerializer.load(chunks[i])
          rescue StandardError => e
            # log any exceptions caused by serializing individual chunks instead
            # of halting EM. each command is discrete so we need to keep trying
            # so long as there are more commands to process (although subsequent
            # commands may lack context if previous commands failed).
            Log.error("Failed parsing command chunk", e, :trace)
          end
        end
        commands.each do |cmd|
          EM.next_tick do
            begin
              @callback.call(cmd)
            rescue Exception => e
              # log any exceptions raised by callback instead of halting EM.
              Log.error("Failed executing parsed command", e, :trace)
            end
          end
        end
        @buildup = chunks.last
      end
      do_call
    rescue StandardError => e
      # log any other exceptions instead of halting EM.
      Log.error("Failed parsing command chunk", e, :trace)
    end
def parse_chunk(chunk)
      @buildup << chunk
      chunks = @buildup.split(CommandSerializer::SEPARATOR, -1)
      if (do_call = chunks.size > 1)
        commands = []
        (0..chunks.size - 2).each do |i|
          begin
            commands << CommandSerializer.load(chunks[i])
          rescue StandardError => e
            # log any exceptions caused by serializing individual chunks instead
            # of halting EM. each command is discrete so we need to keep trying
            # so long as there are more commands to process (although subsequent
            # commands may lack context if previous commands failed).
            Log.error("Failed parsing command chunk", e, :trace)
          end
        end
        commands.each do |cmd|
          EM.next_tick do
            begin
              @callback.call(cmd)
            rescue Exception => e
              # log any exceptions raised by callback instead of halting EM.
              Log.error("Failed executing parsed command", e, :trace)
            end
          end
        end
        @buildup = chunks.last
      end
      do_call
    rescue StandardError => e
      # log any other exceptions instead of halting EM.
      Log.error("Failed parsing command chunk", e, :trace)
    end
Register callback block

 === Block
 Block that will get called back whenever a command is successfully parsed

 === Raise
 (ArgumentError): If block is missing
 Parse given input
 May cause multiple callbacks if multiple commands are successfully parsed
 Callback happens in next EM tick

 === Parameters
 chunk(String):: Chunck of serialized command(s) to be parsed

 === Return
 true:: If callback was called at least once
 false:: Otherwise