src/react/puppeteer/src/js/puppet/CreateTunnel.js
/**
 * Loads a tunnel module on the "srcDevice" which connects
 * to the "destSinkId' sink on the "destDevice" puppet device.
 *
 * @param destDevice The device object that will be streamed to.
 * @param destSinkId The sink id on "destDevice" to stream to.
 * @param srcDevice The device that connects to "destDevice".
 */


@param destDevice The device object that will be streamed to.
@param destSinkId The sink id on "destDevice" to stream to.
@param srcDevice The device that connects to "destDevice".
@param destDevice The device object that will be streamed to . @param destSinkId The sink id on " destDevice " to stream to . @param srcDevice The device that connects to " destDevice " .
function createTunnel(destDevice, destSinkId, srcDevice) {
  const host = srcDevice.get('host');
  const server = getServer(host) + ':4141';
  checkDest(destDevice, (checkDestData) => {
    if (!!checkDestData) {
      $.ajax({
        url: srcDevice.get('host') + '/v1/tunnels',
        method: 'POST',
        contentType: 'application/json',
        accepts: 'application/json',
        data: {
          name: destDevice.get('name'),
          server: server,
          sink: destSinkId,
        },
        beforeSend: (xhr) => {
          xhr.setRequestHeader("Authorization", "Basic " + btoa("nick:something"));
        },
        error: (jqXHR) => {
          console.log("Ajax error: " + jqXHR.status);
        }
      }).done((data) => {
        console.log("Created tunnel! Got:");
        console.log(data);
      });
    }
  });
}
function createTunnel ( destDevice , destSinkId , srcDevice ) { const host = srcDevice . get ( 'host' ) ; const server = getServer ( host ) + ':4141' ; checkDest ( destDevice , ( checkDestData ) => { if ( ! ! checkDestData ) { $ . ajax ( { url : srcDevice . get ( 'host' ) + '/v1/tunnels' , method : 'POST' , contentType : 'application/json' , accepts : 'application/json' , data : { name : destDevice . get ( 'name' ) , server : server , sink : destSinkId , } , beforeSend : ( xhr ) => { xhr . setRequestHeader ( "Authorization" , "Basic " + btoa ( "nick:something" ) ) ; } , error : ( jqXHR ) => { console . log ( "Ajax error: " + jqXHR . status ) ; } } ) . done ( ( data ) => { console . log ( "Created tunnel! Got:" ) ; console . log ( data ) ; } ) ; } } ) ; }
Loads a tunnel module on the "srcDevice" which connects
 to the "destSinkId' sink on the "destDevice" puppet device.
Loads a tunnel module on the " srcDevice " which connects to the " destSinkId ' sink on the " destDevice " puppet device .
/*
   * Checks that the destination device has a port open for connecting
   * a tunnel to, then opens a tunnel on the source device to that
   * port.
   */ /*
     * If the returned data from the "checkDest" call (i.e. the incoming
     * "data" parameter from the ajax "done" callback) indicates that
     * we've successfully opened/found an open port on the destination
     * device, then proceed to open the tunnel from the source device.
     */