במדריך הזה מוסבר איך מגדירים ומפעילים דוגמה תוסף Google Meet.
מטרות
- הגדרת הדוגמה.
- מריצים את הדוגמה.
דרישות מוקדמות
- חשבון Google Workspace עם גישה ל-Google Meet.
- פרויקט ב-Google Cloud.
- Node.js ו-npm מותקנת.
הגדרת הדוגמה
בספריית העבודה, מריצים את הפקודה הבאה כדי לאתחל את project:
npm init
בספריית העבודה, מתקינים את Express.js:
npm install express --save
מתקינים את Meet Add-ons Web SDK:
npm install @googleworkspace/meet-addons --save
בספריית העבודה, יוצרים קובץ בשם
index.js
ומדביקים את הקוד הבא:const express = require('express'); const path = require('path'); var app = express(); app = require("https-localhost")(); app.use(express.static(path.join(__dirname, '/'))); app.use('/', express.static(__dirname + '/node_modules/@googleworkspace/meet-addons')); app.get('/sidepanel', function(req, res){ res.render(path.join(__dirname, 'sidepanel.html')); }); app.get('/mainstage', function(req, res){ res.render(path.join(__dirname, 'mainstage.html')); }); app.listen(3000);
בספריית העבודה, יוצרים קובץ בשם
mainstage.html
ומדביקים את הקוד הבא:<html style="width: 100%; height: 100%"> <head> <title>Main Stage Add On</title> <script src="meet.addons.js"></script> </head> <body style="width: 100%; height: 100%; margin: 0; background: white;"> <div style="display: flex; flex-direction: column; height: 100%"> <h1>Main Stage Add-on</h1> <div> <div> <button id="get-collaboration-starting-state"> getCollaborationStartingState </button> </div> <div id="receivedCollaborationStartingState" style="margin-left: 20px; width: 300px; overflow-wrap: anywhere"></div> </div> </div> <script> let mainStageClient; async function init() { const session = await window.meet.addon.createAddonSession({ cloudProjectNumber: "CLOUD_PROJECT_NUMBER", }); console.log("Successfully constructed the add-on session."); const mainStageClient = await session.createMainStageClient(); console.log("Successfully constructed main stage client."); document .getElementById('get-collaboration-starting-state') .addEventListener( 'click', async () => { document.getElementById( 'receivedCollaborationStartingState').textContent = JSON.stringify( await mainStageClient.getCollaborationStartingState()); }); } document.body.onload = () => { init(); }; </script> </body> </html>
בספריית העבודה, יוצרים קובץ בשם
sidepanel.html
ומדביקים את הקוד הבא:<html style="width: 100%; height: 100%"> <head> <title>Side Panel Add-on</title> <script src="meet.addons.js"></script> </head> <body style="width: 100%; height: 100%; margin: 0"> <div style="display: flex; flex-direction: column; height: 100%"> <h1>Side Panel Add-on</h1> <div> <div> <button id="set-collaboration-starting-state"> setCollaborationStartingState </button> </div> <div> <input type="text" id="sidePanelIframeUrl" style="margin-left: 20px" value="https://localhost:3000/sidepanel.html" /> </div> <div> <input type="text" id="mainStageIframeUrl" style="margin-left: 20px" value="https://localhost:3000/mainstage.html" /> </div> <div> <input type="text" id="additionalData" style="margin-left: 20px" value="additional data" /> </div> </div> </div> <script> let sidePanelClient; async function init() { const session = await window.meet.addon.createAddonSession({ cloudProjectNumber: "CLOUD_PROJECT_NUMBER", }); console.log("Successfully constructed the add-on session."); sidePanelClient = await session.createSidePanelClient(); console.log("Successfully constructed side panel client."); document .getElementById('set-collaboration-starting-state') .addEventListener( 'click', async () => { const sidePanelIframeUrlInputElement = document.getElementById('sidePanelIframeUrl'); const mainStageIframeUrlInputElement = document.getElementById('mainStageIframeUrl'); const additionalDataInputElement = document.getElementById('additionalData'); await sidePanelClient.setCollaborationStartingState({ sidePanelUrl: sidePanelIframeUrlInputElement.value, mainStageUrl: mainStageIframeUrlInputElement.value, additionalData: additionalDataInputElement.value, }); }); } document.body.onload = () => { init(); }; </script> </body> </html>
מחליפים את הערכים הבאים בקובץ
mainstage.html
ובקובץsidepanel.html
:CLOUD_PROJECT_NUMBER
: מספר הפרויקט של פרויקט ב-Google Cloud
בספריית העבודה, מתקינים את https-localhost [חבילה]:
npm install https-localhost --save
בספריית העבודה, מריצים את הדוגמה:
node index.js
בדפדפן, עוברים אל
https://localhost:3000/mainstage.html
ואזhttps://localhost:3000/sidepanel.html
כדי לאמת את דפי האינטרנט.
יצירת התוסף של Meet
כדי להגדיר את הפריסה של התוסף, פועלים לפי השלבים הבאים: איך יוצרים תוסף ל-Meet
הרצת הדוגמה
נכנסים ל-Meet.
לוחצים על פעילויות .
בקטע התוספים שלך אתם אמורים לראות
Google Meet Add-ons Quickstart
. יש לבחור באפשרות הזו כדי להריץ את