Haxe Websockets Remoting with Large Messages

Just a quick addition to my series of posts on the websocket  in haxe series (Part 1, Part 2) …

A significant issue with haxe remoting is that the allowed message size is constrained. This means that when passing parameters that exceed 4kb or so, you’ll get a nasty “message too big” error.

Based on code written by Anthony Loizeau(see this post), my haxe websocket library now supports arbitrarily large messages. It does this by splitting up the haxe serialisation string into pieces, sending them piece by piece through the socket, and then stitching them together on the other end.

The new example unsizedremoting in the code illustrates how to use the new functionality. The client in the example repeatedly calls a server function sendData(s:String) with a string that keeps doubling in size. It gets to around 50kb in size before a noticable message decoding lag occurs (on my eeepc).

You can browse the code, download a zip, or clone it directly:

hg clone websockets

The code is not well tested, but seems to work okay. If you encounter any issues, let me know, and we can make this a nice stable implementation. :)

I must say also, that the latest websockets draft supports multi-part messages. I am not using this functionality in the library, but will probably incorporate it at some time in the future. Right now, the haxe remoting logic uses its own multi-part message handling.