adobe/brackets — pull request #6339 by iwehrman (2013-12-30 23:37:43+00:00)
Title: Receive binary Brackets-Node command responses 

This pull request updates `NodeConnection` so that it can receive binary responses to commands in Node domains. When a binary message --- i.e., an `ArrayBuffer` instance; i.e., an array of bytes; i.e., *not* a string to be interpreted as JSON --- is received via the WebSocket, the first four bytes are assumed to be a header and are interpreted as a (32-bit unsigned integer) command ID. The header is then stripped off and the pending deferred of the corresponding command is resolved with the remaining bytes. Clients can then interpret or process the bytes arbitrarily.

To ensure that the command ID can always be encoded as a 32-bit unsigned integer, IDs are now restricted to the range `0 <= id < 2^32`. When the maximum value is eclipsed, the counter just rolls back to 0. (This could be improved, but the bugs in this PR already exist in the current implementation, so I'm not too worried about it.)

This should be reviewed in tandem with a companion brackets-shell pull request that allows domain commands to return binary responses.

Unit tests still to come.