# File lib/pry-remote-em/proto.rb, line 29
    def receive_data(d)
      return unless d && d.length > 0
      @buffer ||= "" # inlieu of a post_init
      @buffer << d
      while @buffer && !@buffer.empty?
        return unless @buffer.length >= PREAMBLE_LEN &&
          (len_ends = @buffer.index(SEPERATOR)) &&
          (crc_ends = @buffer.index(SEPERATOR, len_ends))
        if (preamble = @buffer[0...PREAMBLE_LEN]) != PREAMBLE
          raise "message is not in proper format; expected #{PREAMBLE.inspect} not #{preamble.inspect}"
        end
        length    = @buffer[PREAMBLE_LEN ... len_ends].to_i
        return if len_ends + length > @buffer.length
        crc_start = len_ends + SEPERATOR_LEN
        crc, data = @buffer[crc_start ... crc_start + length].split(SEPERATOR, 2)
        crc       = crc.to_i
        @buffer   = @buffer[crc_start + length .. -1]
        if (dcrc = Zlib::crc32(data)) == crc
          receive_json(JSON.load(data))
        else
          warn("data crc #{dcrc} doesn't match crc #{crc.inspect}; discarding #{data.inspect}")
        end
      end
      @buffer
    end