Links

Streams JS SDK

You can use Streams JS SDK to send messages from the client side to your application.
Embed the script code between the <head> </head> tags inside the page you embedded your Streams Link via iframe.
<script src="https://app.vagon.io/vagonsdk.js"></script>
Despite you added the JS SDK script between the tags in your client code, if you can not establish a connection, please be sure that you copied the iFrame tag from the Vagon Streams dashboard.
If you manually created your iFrame code by adding your Streams Link, please check that you applied the id tag and other required iFrame properties correctly from the sample code below.
<iframe id="vagonFrame" allow="microphone *; clipboard-read *; clipboard-write *; encrypted-media *;" src="_Stream_URL_"/>
Then you will be able to use the JS methods to create your custom user experience for your application Stream.
Demo HTML
<!DOCTYPE html>
<html>
<head>
<script src="https://app.vagon.io/vagonsdk.js"></script>
</head>
<body>
<iframe id="vagonFrame" style="height:100vh; width: 100vw;" allow="microphone *; clipboard-read *; clipboard-write *; encrypted-media *;" src="__Stream_URL__"/>
</body>
</html>

Functions

isConnected

window.Vagon.isConnected()
Connection status, returns boolean.

sendApplicationMessage

window.Vagon.sendApplicationMessage("Hello My Application!")
Sends the related message to your application.

resizeFrame

window.Vagon.resizeFrame()
Updates the streaming resolution and matches the iframe height and width when initiated.

focusIframe

window.Vagon.focusIframe()
Keeps the browser window focused on the streaming iframe. In case you are facing issues with keyboard inputs, you can use this method.

showKeyboard

window.Vagon.showKeyboard()
If your visitors are using your Applications on mobile/tablet devices, you can also allow them to type with the on-screen keyboard inside Vagon Streams.

hideKeyboard

window.Vagon.hideKeyboard()
When the focus changes from the text input, you can hide the on-screen keyboard button from the screen as well.

enableGameMode

window.Vagon.enableGameMode()
Activates 360 View cursor mode inside an active Stream.

disableGameMode

window.Vagon.disableGameMode()
Disable 360 View cursor mode inside an active Stream.

keepAlive

window.Vagon.keepAlive()
Reset Idle Timer by sending a simulated user input when the Idle Duration Limit is active.

shutDown

window.Vagon.shutDown()
Shut down the Stream Machine and terminate the related session immediately.

setQuality

window.Vagon.setQuality(quality)
Quality parameters can be set as "standard", "moderate" or "high". Session will be refreshed automatically after the quality is set.

getSessionInformation

window.Vagon.getSessionInformation()
Triggers the onSessionInformation event, data must be collected via onSessionInformation event.

Events

All events except onApplicationMessage is only available in Enterprise Plan.

onApplicationMessage

Prints out the message sent from the application, for application-side integration please check Unreal Engine and Unity SDKs.
window.Vagon.onApplicationMessage(evt => {
console.log(evt.message);
});

onInitialization

Prints out the message during the Stream initialization process.
window.Vagon.onInitialization(() => {
console.log("Application is Initializing");
});

onPreparingAssets

Prints out the message during the pixel streaming asset preparation process. Only available in Pixel Streaming enabled Streams.
window.Vagon.onPreparingAssets(() => {
console.log("Application is Preparing Assets");
});

onInstalling

Prints out the message when application is on installing state.
window.Vagon.onInstalling(() => {
console.log("Application Installing");
});

onConnected

Prints out the message when user is connected.
window.Vagon.onConnected(() => {
console.log("User Connected");
});

onDisconnected

Prints out the message when user is disconnected.
window.Vagon.onDisconnected(() => {
console.log("User Disconnected");
});

onInactive

Prints out the message when user is inactive. Only available when Idle Duration Limit is active.
window.Vagon.onInactive(() => {
console.log("User Inactive");
});

onInstallationFailed

Prints out the message when app installation is failed.
window.Vagon.onInstallationFailed(() => {
console.log("App Installation is Failed");
});

onFailed

Prints out the message when connection is failed.
window.Vagon.onFailed(() => {
console.log("Connection is Failed");
});

onSessionInformation

Prints out the message when connection is failed.
window.Vagon.onSessionInformation((session_data) => {
console.log(session_data);
});
Sample Session Data
{
"session": {
ping: 150, // Available for Session Data Collection enabled Streams.
os: "windows", // Available for Session Data Collection enabled Streams.
device_type: "desktop", // Available for Session Data Collection enabled Streams.
},
"machine": {
"status": "runinng",
"friendly_status": "ready",
"connection_status": "connected",
"region": "dublin",
"uid": "05545648-c292-4ef4-b571-d10797f83069",
"application_id": 1,
"stream_id": 1,
"machine_id": 1,
}
}