You are here: Recent News » Documentation Pages List » AMF3 Specification » parsing byte arrays

 



parsing byte arrays

def readAMF3ByteArray(self):
 typ = self.readAMF3Integer()
 isReference = (typ & 0x01) == 0
 if isReference:
  reference = typ >> 1
  if reference < len(self.objectReferences):
   if not self.objectReferences[reference]:
    raise ReferenceError #
   return self.objectReferences[reference]
  else:
   raise ReferenceError
 else:
  length = typ >> 1
  try: #first assume we used byteArray.compress() from flash / flex
   inflatedStream = zlib.decompress(self.stream[self.streamIndex:length])
   arr = unpack('c'*len(inflatedStream), inflatedStream)
  except: #if an exception happens, it wasn't compressed
   arr = unpack('c'*length, self.stream[self.streamIndex:length])
  self.streamIndex += length
  self.objectReferences.append(arr)
  return arr

documentation/amf3/parsing_byte_arrays.txt · Last modified: 2007/11/06 22:27 by aaronsmith