rksm/node-nrepl-client — pull request #2 by ilkka (2014-03-05 09:37:02+00:00)
Title: Add handling for multiple messages in one dgram

As documented in #1, sometimes the nREPL sends several concatenated messages at once. Bencode decoding only decodes the first complete dict from the buffer, and this sometimes causes the client to hang, because it throws away the rest of the buffer, and the status array is in that part. Therefore the client
never sees the 'done' status of the server and never calls `messageReceiveDone`.

This change iterates over the buffer by checking how many bytes were decoded and slicing that off the beginning.

The status array check is only made for the last message because the nREPL protocol spec states that the done status is only sent when processing the message is done, done, done.