function dispatchOnMessage(msg, portId) {
    var port = ports[portId];
    if (port) {
      if (msg)
        msg = $JSON.parse(msg);
      port.onMessage.dispatch(msg, port);
    }
  }
// Called by native code when a message has been sent to the given port.
Called by native code when a message has been sent to the given port.
Called by native code when a message has been sent to the given port .
function dispatchOnMessage(msg, portId) {
    var port = ports[portId];
    if (port) {
      if (msg)
        msg = $JSON.parse(msg);
      port.onMessage.dispatch(msg, port);
    }
  }
function dispatchOnMessage ( msg , portId ) { var port = ports [ portId ] ; if ( port ) { if ( msg ) msg = $JSON . parse ( msg ) ; port . onMessage . dispatch ( msg , port ) ; } }
Called by native code when a message has been sent to the given port.
Called by native code when a message has been sent to the given port .