src/protocol/messages.js
function writeMessage(message, socket, signer) {
  var header = JSON.stringify(message.header);
  var parentHeader = JSON.stringify(message.parentHeader);
  var metadata = JSON.stringify(message.metadata);
  var content = JSON.stringify(message.content);

  var signature = signer.sign([ header, parentHeader, metadata, content ]);

  var socketData = [
    message.identities,
    '<IDS|MSG>',
    signature,
    header,
    parentHeader,
    metadata,
    content
  ];
  socket.send(socketData);
}
function writeMessage(message, socket, signer) {
  var header = JSON.stringify(message.header);
  var parentHeader = JSON.stringify(message.parentHeader);
  var metadata = JSON.stringify(message.metadata);
  var content = JSON.stringify(message.content);

  var signature = signer.sign([ header, parentHeader, metadata, content ]);

  var socketData = [
    message.identities,
    '<IDS|MSG>',
    signature,
    header,
    parentHeader,
    metadata,
    content
  ];
  socket.send(socketData);
}
Helper to write out a message to as outgoing message data.