Controlling the Application
Bring your own
If your application provides a websocket endpoint for control make sure to listen on port 5555 and our service will proxy incoming connections to the application.
When your stream is established you can connect to your application.
Use the 'publicDomainName' spec to connect.
Establish a control connection on stream start
const videoElem; // HTML video element for the stream
const streamInfo$ = streaming.start();
streamInfo$.subscribe({
next: info => {
if (!info) {
// session ended
} else {
// session established
const applicationUrl = `wss://{info.renderer.specs.publicDomainName}/`;
// establish connection to your application
videoElem.srcObject = info.stream;
videoElem.play();
}
},
error: async err => {
// error establishing streaming session
if (err instanceof SessionNotAvailableError) {
// no session available
}
}
});
Use the MonkeyWay control library
You can also use our library enabling the use of mouse/touch and keyboard to control your application.
Install the control library
npm install @monkeyway/streaming-control-lib
Use the library to control your application
const videoElem; // HTML video element for the stream
let streamingControl = new StreamingControlService();
const streamInfo$ = streaming.start();
streamInfo$.subscribe({
next: info => {
if (!info) {
// session ended
} else {
// session established
const options = streamingControl.createOptions(info);
streamingControl.connect(videoElem, options)
.subscribe(_ => {
// control connection established
videoElem.srcObject = info.stream;
videoElem.play();
}, async err => {
// error establishing control connection
await streaming.stop();
});
}
},
error: async err => {
// error establishing streaming session
if (err instanceof SessionNotAvailableError) {
// no session available
}
}
});