virtual-keypad 4.0.7 → 5.0.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/dist/receiver.html +4 -5
- package/package.json +1 -1
- package/src/receiver.js +4 -5
package/dist/receiver.html
CHANGED
|
@@ -86,11 +86,10 @@
|
|
|
86
86
|
var receiver = new virtualKeypad.Receiver(
|
|
87
87
|
keypad_options,
|
|
88
88
|
ondata_callback,
|
|
89
|
-
()=>console.log("Handshake complete"),
|
|
90
|
-
()=>console.log("Connection
|
|
91
|
-
()=>console.log("Connection
|
|
92
|
-
()=>console.log("Connection
|
|
93
|
-
()=>console.log("Connection error")
|
|
89
|
+
()=>console.log("RECEIV Handshake complete"),
|
|
90
|
+
()=>console.log("RECEIV Connection connected"),
|
|
91
|
+
()=>console.log("RECEIV Connection closed"),
|
|
92
|
+
()=>console.log("RECEIV Connection error")
|
|
94
93
|
);
|
|
95
94
|
</script>
|
|
96
95
|
</body>
|
package/package.json
CHANGED
package/src/receiver.js
CHANGED
|
@@ -5,17 +5,16 @@ import { KeypadPeer } from "./keypadPeer.js";
|
|
|
5
5
|
|
|
6
6
|
const doNothing = () => undefined;
|
|
7
7
|
|
|
8
|
-
class Receiver extends KeypadPeer {
|
|
9
8
|
/**
|
|
10
9
|
* @param {{alphabet: string[], font:string}} keypadParameters
|
|
11
10
|
* @param {(data) => void} onDataCallback
|
|
12
11
|
* @param {() => void} handshakeCallback
|
|
13
|
-
* @param {() => void} customDisonnectedCallback
|
|
14
12
|
* @param {(connection) => void} customConnectionCallback
|
|
15
13
|
* @param {() => void} customCloseCallback
|
|
16
14
|
* @param {(error) => void} customErrorCallback
|
|
17
15
|
*/
|
|
18
|
-
|
|
16
|
+
class Receiver extends KeypadPeer {
|
|
17
|
+
constructor(keypadParameters, onDataCallback=doNothing, handshakeCallback=doNothing, customConnectionCallback=doNothing, customCloseCallback=doNothing, customErrorCallback=doNothing) {
|
|
19
18
|
super({ targetElementId: keypadParameters.targetElementId });
|
|
20
19
|
keypadParameters = this.#verifyKeypadParameters(keypadParameters);
|
|
21
20
|
|
|
@@ -25,14 +24,13 @@ class Receiver extends KeypadPeer {
|
|
|
25
24
|
this.onData = onDataCallback; // What to do on a button-press
|
|
26
25
|
this.onHandshake = handshakeCallback; // What to do when the connection is established
|
|
27
26
|
this.onConnection = (connection) => {customConnectionCallback(connection); this.#onPeerConnection(connection)};
|
|
28
|
-
this.onDisconnected = () => {customDisonnectedCallback(); this.onPeerDisconnected()};
|
|
29
27
|
this.onClose = () => {customCloseCallback(); this.onPeerClose()};
|
|
30
28
|
this.onError = (err) => {customErrorCallback(err); this.onPeerError(err)};
|
|
31
29
|
|
|
32
30
|
/* Set up callbacks that handle any events related to our peer object. */
|
|
33
31
|
this.peer.on("open", this.#onPeerOpen); // On creation of Receiver (local) Peer object
|
|
34
32
|
this.peer.on("connection", this.onConnection); // On connection with Keypad (remote) Peer object
|
|
35
|
-
this.peer.on("disconnected", this.
|
|
33
|
+
this.peer.on("disconnected", this.onPeerDisconnected);
|
|
36
34
|
this.peer.on("close", this.onClose);
|
|
37
35
|
this.peer.on("error", this.onError);
|
|
38
36
|
}
|
|
@@ -170,6 +168,7 @@ class Receiver extends KeypadPeer {
|
|
|
170
168
|
}
|
|
171
169
|
});
|
|
172
170
|
this.conn.on("close", () => {
|
|
171
|
+
this.onClose();
|
|
173
172
|
this.displayUpdate("Connection reset. Awaiting connection...");
|
|
174
173
|
this.conn = null;
|
|
175
174
|
});
|