virtual-keypad 5.0.0 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +1 -1
- package/dist/main.js.map +1 -1
- package/package.json +1 -1
- package/src/keypad.js +2 -0
- package/src/receiver.js +3 -3
package/package.json
CHANGED
package/src/keypad.js
CHANGED
|
@@ -122,6 +122,8 @@ class Keypad extends KeypadPeer {
|
|
|
122
122
|
console.log("No target element used.");
|
|
123
123
|
document.getElementsByTagName("main")[0].appendChild(keypadElem);
|
|
124
124
|
}
|
|
125
|
+
window.onbeforeunload = () => {this.conn?.close(); console.log("closing connection on page unload.")};
|
|
126
|
+
window.onvisibilitychange = () => {this.conn?.close(); console.log("closing connection on page unload.")};
|
|
125
127
|
};
|
|
126
128
|
#populateKeypad = () => {
|
|
127
129
|
const buttonResponseFn = (button) => {
|
package/src/receiver.js
CHANGED
|
@@ -23,9 +23,9 @@ class Receiver extends KeypadPeer {
|
|
|
23
23
|
|
|
24
24
|
this.onData = onDataCallback; // What to do on a button-press
|
|
25
25
|
this.onHandshake = handshakeCallback; // What to do when the connection is established
|
|
26
|
-
this.onConnection = (connection) => {
|
|
27
|
-
this.onClose = () => {
|
|
28
|
-
this.onError = (err) => {
|
|
26
|
+
this.onConnection = (connection) => {this.#onPeerConnection(connection); customConnectionCallback(connection)};
|
|
27
|
+
this.onClose = () => {this.onPeerClose(); customCloseCallback()};
|
|
28
|
+
this.onError = (err) => {this.onPeerError(err); customErrorCallback(err)};
|
|
29
29
|
|
|
30
30
|
/* Set up callbacks that handle any events related to our peer object. */
|
|
31
31
|
this.peer.on("open", this.#onPeerOpen); // On creation of Receiver (local) Peer object
|