LocalConnection in Gnash

This week I implemented the LocalConnection ActionScript class in Gnash. It is too late for Gnash 0.8.7, which should be released imminently. But the six months of testing before the next release are certainly a good thing where this code is concerned.

LocalConnection allows the player to communicate with other players or instances using shared memory. It is even used for communication between AS2 and AS3 loaded in the same SWF, since they can't otherwise talk to each other.

Until now there has been only sparse documentation of the LocalConnection. It was known that it used AMF, a well-documented serialization format for ActionScript values. A useful page at osflash.org documented the memory layout and had some example windows code.

However, the protocol for reading and writing was not very well known, and there was no code at all for POSIX systems.

I spent a long time watching what the Flash player wrote in its shared memory section, then began to write to the memory myself to see how it responded. This was important to find out when the memory should be read, when it could be overwritten, and how and when data expires.

Gnash still doesn't have it completely right, but it is good enough to allow communication both ways between Gnash and the proprietary Flash player.

I also updated the osflash.org page with a description of the Linux implementation and some other previously missing information. With that data, it is also trivial to write a stand-alone application to communicate with the flash player.