[SabreAMF] SabreAMF and ByteArray
Evert | Rooftop
evert at rooftopsolutions.nl
Tue Nov 14 12:22:26 EST 2006
The best way to do something like this is a class-wrapper, because I
think 'magic' behaviour is a really bad thing..
So.. this would be something like:
$byteArray = new SabreAMF_ByteArray($data);
If you can give me an AMF sample, I can probably implement this pretty
Jim Mischel wrote:
> SabreAMF does not currently support AMF type 0x0C, which is a Flash
> ByteArray. Looking at a dump of the AMF created when I pass a
> ByteArray, it appears that the ByteArray format is very similar to the
> String format. That is, 0x0C followed by an integer-data length,
> followed by the bytes in the array. As with Strings, the low bit of the
> length determines whether it's a literal ByteArray or a reference to a
> previous ByteArray.
> It would be simple enough to code up something that reads this data
> type, but there's a problem: there is no PHP data type that corresponds
> to a ByteArray. It appears that I can use a PHP string to hold the
> bytes, but that becomes problematic on serialization. If the serializer
> sees a string, how does it know whether output it as a String (type
> 0x06) or a ByteArray (type 0x0C)? Being something of a PHP novice, I
> could be missing something. But there doesn't appear to be a distinct
> PHP data type that I can use for the ByteArray.
> The solution I stumbled on was to mangle the name of the ByteArray when
> I read it. For example, if I get a ByteArray field called 'data', I
> mangle the name by adding (prepending or appending) something to the
> field name. 'data', for example, would become 'data_BA' (for
> ByteArray). This, of course, requires that I either mangle every field
> name by adding its type, or tell clients that they can't use variables
> that end in '_BA' (or whatever the mangling characters are).
> The other problem with this approach is ... mangled names. And mangled
> names are a serious pain to work with, as we discovered years ago when
> working with the Hungarian notation so common in old-style Windows
> programming. lpszFileName, and all that rot.
> Any thoughts on this one? Suggestions how to handle ByteArray?
> sabreamf mailing list
> sabreamf at osflash.org
More information about the sabreamf