AmfSerializer manages the job of translating PHP objects into the actionscript equivalent via Amf. The main method of the serializer is the serialize method which takes and AmfObject as it's argument and builds the resulting Amf Message.
TODO spit into 2 classes, one for Amf0 , one for Amf3 or maybe more.
Located in /Amfphp/Core/Amf/Serializer.php (line 22)
| Class | Description |
|---|---|
| AmfSerializerWrapper | This class exports some internal (public) methods. This way, those methods can be tested separately. |
Return the serialisation of the given integer (Amf3).
note: There does not seem to be a way to distinguish between signed and unsigned integers. This method just sends the lowest 29 bit as-is, and the receiver is responsible to interpret the result as signed or unsigned based on some context.
note: The limit imposed by Amf3 is 29 bit. So in case the given integer is longer than 29 bit, only the lowest 29 bits will be serialised. No error will be logged!
serializes the Packet passed in the constructor TODO clean up the mess with the temp buffers. A.S.
Write an ArrayCollection
Write a boolean (Amf3).
Write an (un-)signed integer (Amf3).
Write NULL (Amf3).
Serialise the array as if it is an object.
Write a string (Amf3). Strings are stored in a cache and in case the same string is written again, a reference to the string is sent instead of the string itself.
note: Sending strings larger than 268435455 (2^28-1 byte) will (silently) fail!
note: The string marker is NOT sent here and has to be sent before, if needed.
Write undefined (Amf3).
writeObject handles writing a php array with string or mixed keys. It does not write the object code as that is handled by the writeArrayOrObject and this method is shared with the CustomClass writer which doesn't use the object code.
writeArrayOrObject first deterines if the PHP array contains all numeric indexes or a mix of keys. Then it either writes the array code (0x0A) or the object code (0x03) and then the associated data.
writeBoolean writes the boolean code (0x01) and the data to the output stream
writeByte writes a singe byte to the output stream 0-255 range
writeData checks to see if the type was declared and then either auto negotiates the type or relies on the user defined type to serialize the data into Amf
writeData writes the date code (0x0B) and the date value to the output stream
writeDouble takes a float as the input and writes it to the output stream.
Then if the system is big-endian, it reverses the bytes order because all doubles passed via remoting are passed little-endian.
writeInt takes an int and writes it as 2 bytes to the output stream 0-65535 range
writeLong takes an int, float or double and converts it to a 4 byte binary string and adds it to the output buffer
writeLongUTF will write a string longer than 65535 characters.
It works exactly as writeUTF does except uses a long for the length flag.
writeNull writes the null code (0x05) to the output stream
writeNumber writes the number code (0x00) and the numeric data to the output stream All numbers passed through remoting are floats.
writeObjectEnd writes the object end code (0x009) to the output stream
writeObjectFromArray handles writing a php array with string or mixed keys. It does not write the object code as that is handled by the writeArrayOrObject and this method is shared with the CustomClass writer which doesn't use the object code.
Write a plain numeric array without anything fancy
writeString writes the string code (0x02) and the UTF8 encoded string to the output stream.
Note: strings are truncated to 64k max length. Use XML as type to send longer strings
writeTypedObject takes an instance of a class and writes the variables defined in it to the output stream.
To accomplish this we just blanket grab all of the object vars with get_object_vars, minus the Amfphp_Core_Amf_Constants::FIELD_EXPLICIT_TYPE field, whiuch is used as class name
writeUndefined writes the Undefined code (0x06) to the output stream
writeUTF takes and input string, writes the length as an int and then appends the string to the output buffer
writeXML writes the xml code (0x0F) and the XML string to the output stream
Note: strips whitespace
Documentation generated on Thu, 24 Mar 2011 16:55:41 +0100 by phpDocumentor 1.4.3