1.1.0 • Published 1 year ago

@rbbn/distant-electron-vdi v1.1.0

Weekly downloads
-
License
SEE LICENSE IN LI...
Repository
-
Last release
1 year ago

Distant Electron VDI

High level management of VDI capabilities. These include:

  • Creating Distant Controllers
  • Managing Virtual Channels
  • Creating Distant Sessions
  • Sending messages to a Distant Session

Usage

const { VDI } = require('distant-electron-vdi')

const moduleName = 'vdiModule'
const url = 'https://example/my/remote/application'
const id = 123

function handleVDIMessage(type, data) {
  ...
}

async function setup() {
  // Create instance
  const vdi = vdi = new VDI(url, moduleName, handleVDIMessage)

  // Create channel handle and Distant Controller
  await this.vdi.init()

  // Create session with automatic event handling
  // `handleVDIMessage()` will receive messages of type `sessionInfo`, `sdkMessage` and `logMessage`
  await vdi.createSessionWithEventHandling(id)

  // Send a message to the remote application
  vdi.sendSessionMessage(id, 'sdkMessage', { data: 'hello' })

  // Create another session with a different remote application URL and specific timeout value
  const differentID = 456
  const differentURL = 'https://different/url/for/remote/application'
  const timeout = 3000

  await vdi.createSessionWithEventHandling(differentID, differentURL, timeout)

  // Close session by ID
  vdi.closeSession(id)

  // Shut down: close all sessions, destroy channel handle and destroy Distant Controller
  await vdi.close()
}