שימוש בהעברת הודעות מהפריים למסגרת
בדף הזה מוסבר איך לשלוח הודעות בצד הלקוח מתוסף שפועל ב-iframe של החלונית הצדדית לתוסף שפועל ב-iframe של השלב הראשי. העברת ההודעות מתבצעת רק מצד הלקוח, כך שהעברת ההודעות היא כמעט מיידית.
כדי לשלוח הודעה:
- כדי להעביר את התמונה מהחלונית הצדדית לשידור הראשי, משתמשים ב-method
notifyMainStage()
.
await sidePanelClient.notifyMainStage("YOUR_MESSAGE");
await mainStageClient.notifySidePanel("YOUR_MESSAGE");
האורך של payload
חייב לעמוד במגבלת הגודל שצוינה.
כדי לקבל את ההודעה, התוסף צריך להירשם ל-callback frameToFrameMessage
. דוגמת הקוד הבאה מראה איך להירשם להודעת חזרה (callback) של frameToFrameMessage
:
sidePanelClient.on('frameToFrameMessage', (arg: FrameToFrameMessage) => {
// YOUR_CODE
});
תוסף לדוגמה 'אנימציה' ב-GitHub כולל דוגמה מלאה לשליחת הודעות מפריים לפריים. אחרי שהפעילות מתחילה, החלונית הצדדית מעדכנת את הבמה הראשית בכל פעם שהמשתמש משנה קלט.
הבמה הראשית גם נרשמת לקריאה החוזרת frameToFrameMessage
כדי לקבל את המצב המעודכן.
הערות
הודעות מסגרת-למסגרת שנשלחות על ידי משתתף מסוים גלויות רק לו. כדי לשלוח הודעות או מצב למשתתפים אחרים, תוכלו לקרוא איך משתפים את המצב של התוסף.
המערכת תנסה לשלוח את ההודעה רק פעם אחת. כדי לקבל הודעות, צריך לפתוח את הלוח המקבל והאפליקציה צריכה להירשם לשיחה החוזרת לפני שליחת ההודעה.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2024-12-21 (שעון UTC).
[null,null,["עדכון אחרון: 2024-12-21 (שעון UTC)."],[[["This page explains how Google Meet add-ons can send messages between the side panel and main stage iframes using client-side frame-to-frame messaging."],["Add-ons use `notifyMainStage()` and `notifySidePanel()` methods to send messages and subscribe to the `frameToFrameMessage` callback to receive them."],["Frame-to-frame messages are only visible to the sender and require the receiving panel to be open and subscribed to the callback for delivery."],["For sharing state with other participants, refer to the guide on add-on state collaboration."]]],["Add-ons in different iframes (side panel and main stage) can exchange messages client-side. The side panel sends messages to the main stage using `notifyMainStage()`, while the main stage uses `notifySidePanel()` to send messages to the side panel. To receive messages, add-ons must subscribe to the `frameToFrameMessage` callback. Messages are participant-specific and delivered once; the receiving panel must be open and subscribed. Payload size limitations apply. The Animation sample add-on demonstrates this functionality.\n"]]