Skip to content

Commit

Permalink
feat: Create QR from id
Browse files Browse the repository at this point in the history
  • Loading branch information
carla-at-wiris committed Oct 15, 2024
1 parent 7676482 commit 48cb701
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@
"packages/**",
"demos/**"
],
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610"
"packageManager": "yarn@1.22.22+sha1.ac34549e6aa8e7ead463a7407e1c7390f61a6610",
"dependencies": {
"qrcode": "^1.5.4"
}
}
12 changes: 11 additions & 1 deletion packages/devkit/src/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import maxIcon from "../styles/icons/general/max_icon.svg"; //eslint-disable-lin
import maxHoverIcon from "../styles/icons/hover/max_icon_h.svg"; //eslint-disable-line
import qrIcon from "../styles/icons/general/qr_icon.svg"; //eslint-disable-line
import qrIconPNG from "../styles/icons/qr-code-scan.png"; //eslint-disable-line
import QRCode from "qrcode";

/**
* @typedef {Object} DeviceProperties
Expand Down Expand Up @@ -91,7 +92,7 @@ export default class ModalDialog {

// Identifier for the mobile session
this.mobileSessionID = null;
this.#ws = new WebSocket("ws://localhost:3030"); // Should be a constant open server.
this.#ws = new WebSocket("ws://192.168.0.24:8080"); // Should be a constant open server.
this.#startedMbSession = false;

// Handle server events
Expand All @@ -100,6 +101,15 @@ export default class ModalDialog {

if (data.type === "sessionStarted") {
this.mobileSessionID = data.sessionId;

QRCode.toDataURL(data.sessionId.toString())
.then((url) => {
console.log(url);
})
.catch((err) => {
console.error(err);
});

alert(`Started session on: ${data.sessionId}`);
} else if (data.type === "messageReceived") {
console.log("receiving mathml");
Expand Down

0 comments on commit 48cb701

Please sign in to comment.