Skip to content
This repository was archived by the owner on Jun 9, 2023. It is now read-only.

Embed Paperspace VM Streams into your page

Michael Lunøe edited this page Sep 16, 2019 · 2 revisions

Usage of the streams object:

const { streams } = require('@paperspace/client-sdk');

const vmStreamNode = document.querySelector('.vmStreamNode'); // This could also be an iframe, if you want more control!
const vmInfo = {
  accessToken, // Make a request to your server to retrieve an accessToken using paperspace-node: https://paperspace.github.io/paperspace-node/resourceDelegations.html#.create
  machineId // Make a request to your server to retrieve machineId using paperspace-node: https://paperspace.github.io/paperspace-node/machines.html#.list
};
streams.createStream(vmStreamNode, vmInfo).then(function (stream) {
  stream.open();
 // Run `stream.destroy();` when done
});

Usage of streams.internalApi:

const { streams } = require('@paperspace/client-sdk');

// Declare your open VM request handler
streams.internalApi.onOpenVmRequest = function openVmRequestHandler(vmInfo) {
  // a stream with vmInfo was requested to be opened
};
streams.internalApi.ready();
Clone this wiki locally