Skip to content

Commit

Permalink
Add reconnect function
Browse files Browse the repository at this point in the history
that disconnects and restart webrtc connection
and also rebinds input listeners
  • Loading branch information
pgivel committed Sep 25, 2024
1 parent 5f5460f commit d4c7480
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/DeviceRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,27 @@ module.exports = class DeviceRenderer {
}
}

/**
* Reconnect the instance. Disconnect the current instance, and then
* attempt to reconnect.
*
* When reconnecting, it will attempt to add the previous keyboard and mouse
* callbacks. (including keyboard mapping if applicable)
*/
reconnect() {
this.disconnect();
this.onWebRTCReady();
if (this.store.state.isKeyboardEventsEnabled) {
this.keyboardEvents.addKeyboardCallbacks();
}
if (this.store.state.isMouseEventsEnabled) {
this.mouseEvents.addMouseCallbacks();
}
if (!this.store.state.isKeyboardEventsEnabled && !this.store.state.isMouseEventsEnabled) {
this.keyboardMapping.addKeyboardCallbacks();
}
}

/**
* Send event to the instance through the Websocket connection.
*
Expand Down

0 comments on commit d4c7480

Please sign in to comment.