@rbbn/distant-werkout-vdi
v1.2.0
Published
High level management of VDI capabilities. These include: - Creating Distant Controllers - Managing Virtual Channels - Creating Distant Sessions - Sending messages to a Distant Session
Downloads
4
Readme
Distant Werkout 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-werkout-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()
}