function handleMessage(message_event) {
  var data = message_event.data;
  if ((typeof(data) === 'string' || data instanceof String)) {
    common.logMessage(data);
  } else if (data instanceof Object) {
    var pipeName = data['pipe']
    if (pipeName !== undefined) {
      // Message for JavaScript I/O pipe
      var operation = data['operation'];
      if (operation == 'write') {
        $('pipe_output').value += ArrayBufferToString(data['payload']);
      } else if (operation == 'ack') {
        common.logMessage(pipeName + ": ack:" + data['payload']);
      } else {
        common.logMessage('Got unexpected pipe operation: ' + operation);
      }
    } else {
      // Result from a function call.
      var params = data.args;
      var funcName = data.cmd;
      var callback = funcToCallback[funcName];

      if (!callback) {
        common.logMessage('Error: Bad message ' + funcName +
                          ' received from NaCl module.');
        return;
      }

      delete funcToCallback[funcName];
      callback.apply(null, params);
    }
  } else {
    common.logMessage('Error: Unknow message `' + data +
                      '` received from NaCl module.');
  }
}
// Called by the common.js module.
Called by the common.js module.
Called by the common . js module .
function handleMessage(message_event) {
  var data = message_event.data;
  if ((typeof(data) === 'string' || data instanceof String)) {
    common.logMessage(data);
  } else if (data instanceof Object) {
    var pipeName = data['pipe']
    if (pipeName !== undefined) {
      var operation = data['operation'];
      if (operation == 'write') {
        $('pipe_output').value += ArrayBufferToString(data['payload']);
      } else if (operation == 'ack') {
        common.logMessage(pipeName + ": ack:" + data['payload']);
      } else {
        common.logMessage('Got unexpected pipe operation: ' + operation);
      }
    } else {
      var params = data.args;
      var funcName = data.cmd;
      var callback = funcToCallback[funcName];
      if (!callback) {
        common.logMessage('Error: Bad message ' + funcName +
                          ' received from NaCl module.');
        return;
      }
      delete funcToCallback[funcName];
      callback.apply(null, params);
    }
  } else {
    common.logMessage('Error: Unknow message `' + data +
                      '` received from NaCl module.');
  }
}
function handleMessage ( message_event ) { var data = message_event . data ; if ( ( typeof ( data ) === 'string' || data instanceof String ) ) { common . logMessage ( data ) ; } else if ( data instanceof Object ) { var pipeName = data [ 'pipe' ] if ( pipeName !== undefined ) { var operation = data [ 'operation' ] ; if ( operation == 'write' ) { $ ( 'pipe_output' ) . value += ArrayBufferToString ( data [ 'payload' ] ) ; } else if ( operation == 'ack' ) { common . logMessage ( pipeName + ": ack:" + data [ 'payload' ] ) ; } else { common . logMessage ( 'Got unexpected pipe operation: ' + operation ) ; } } else { var params = data . args ; var funcName = data . cmd ; var callback = funcToCallback [ funcName ] ; if ( ! callback ) { common . logMessage ( 'Error: Bad message ' + funcName + ' received from NaCl module.' ) ; return ; } delete funcToCallback [ funcName ] ; callback . apply ( null , params ) ; } } else { common . logMessage ( 'Error: Unknow message `' + data + '` received from NaCl module.' ) ; } }
Called by the common.js module.
Called by the common . js module .
// Message for JavaScript I/O pipe // Result from a function call.