از پیام فریم به فریم استفاده کنید
با مجموعهها، منظم بمانید
ذخیره و طبقهبندی محتوا براساس اولویتهای شما.
این صفحه نحوه ارسال پیام در سمت سرویس گیرنده را از یک افزونه در حال اجرا در iframe پانل جانبی به یک افزونه در حال اجرا در iframe مرحله اصلی توضیح می دهد. پیام فریم به فریم فقط در سمت مشتری انجام می شود، بنابراین تحویل پیام تقریباً آنی است.
برای ارسال پیام:
await sidePanelClient.notifyMainStage("YOUR_MESSAGE");
await mainStageClient.notifySidePanel("YOUR_MESSAGE");
طول payload
باید با محدودیت اندازه مشخص شده مطابقت داشته باشد.
برای دریافت پیام، افزونه باید در پاسخ به تماس frameToFrameMessage
مشترک شود. نمونه کد زیر نحوه اشتراک در یک فراخوان frameToFrameMessage
را نشان می دهد:
sidePanelClient.on('frameToFrameMessage', (arg: FrameToFrameMessage) => {
// YOUR_CODE
});
نمونه افزودنی «انیمیشن» در GitHub شامل یک نمونه کامل از پیامرسانی فریم به فریم است. پس از شروع فعالیت، هر زمان که کاربر یک ورودی را تغییر دهد، پانل کناری به مرحله اصلی اطلاع میدهد . مرحله اصلی همچنین برای دریافت وضعیت بهروز شده، در بازگشت به تماس frameToFrameMessage
مشترک میشود .
یادداشت ها
پیام های فریم به فریم ارسال شده توسط یک شرکت کننده خاص فقط توسط همان شرکت کننده قابل مشاهده است. برای ارسال پیام یا وضعیت به سایر شرکتکنندگان، نحوه اشتراکگذاری وضعیت افزودنی را بیاموزید.
تحویل پیام فقط یک بار انجام می شود. برای دریافت پیام ها، پنل دریافت باید باز باشد و برنامه باید قبل از ارسال پیام مشترک تماس پاسخگو باشد.
جز در مواردی که غیر از این ذکر شده باشد،محتوای این صفحه تحت مجوز Creative Commons Attribution 4.0 License است. نمونه کدها نیز دارای مجوز Apache 2.0 License است. برای اطلاع از جزئیات، به خطمشیهای سایت Google Developers مراجعه کنید. جاوا علامت تجاری ثبتشده Oracle و/یا شرکتهای وابسته به آن است.
تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی.
[null,null,["تاریخ آخرین بهروزرسانی 2025-08-29 بهوقت ساعت هماهنگ جهانی."],[],[],null,["# Use frame-to-frame messaging\n\nThis page describes how to send messages on the client side from an\nadd-on running in the\n[side-panel](/workspace/meet/add-ons/guides/overview#side-panel) iframe to an\nadd-on running in the [main\nstage](/workspace/meet/add-ons/guides/overview#main-stage) iframe. Frame-to-frame\nmessaging only occurs on the client side, so message delivery is near\ninstantaneous.\n\nTo send a message:\n\n- From the side panel to the main stage, use the [`notifyMainStage()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetsidepanelclient.notifymainstage) method.\n\n await sidePanelClient.notifyMainStage(\"\u003cvar translate=\"no\"\u003eYOUR_MESSAGE\u003c/var\u003e\");\n\n- From the main stage to the side panel, use the [`notifySidePanel()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetmainstageclient.notifysidepanel) method.\n\n await mainStageClient.notifySidePanel(\"\u003cvar translate=\"no\"\u003eYOUR_MESSAGE\u003c/var\u003e\");\n\nThe [`payload`](/workspace/meet/add-ons/reference/websdk/addon_sdk.frametoframemessage.payload)\nlength must conform to its specified size limit.\n\nTo receive the message, the add-on must subscribe to\nthe\n[`frameToFrameMessage`](/workspace/meet/add-ons/reference/websdk/addon_sdk.addoncallbacks.frametoframemessage)\ncallback. The following code sample shows how to subscribe to a\n`frameToFrameMessage` callback: \n\n sidePanelClient.on('frameToFrameMessage', (arg: FrameToFrameMessage) =\u003e {\n // YOUR_CODE\n });\n\nThe [\"Animation\" sample add-on on GitHub](https://github.com/googleworkspace/meet/tree/3311b735550b8927c8b7ef2c6d06f768d9fe0476/addons-web-sdk/samples/animation-next-js)\nincludes a full example of frame-to-frame messaging. After the activity starts,\nthe side panel [notifies the main stage whenever the user changes an input](https://github.com/googleworkspace/meet/blob/3311b735550b8927c8b7ef2c6d06f768d9fe0476/addons-web-sdk/samples/animation-next-js/src/app/activitysidepanel/page.tsx#L27).\nThe main stage also [subscribes to the `frameToFrameMessage` callback](https://github.com/googleworkspace/meet/blob/3311b735550b8927c8b7ef2c6d06f768d9fe0476/addons-web-sdk/samples/animation-next-js/src/app/mainstage/page.tsx#L43)\nto receive updated state.\n\nNotes\n-----\n\n- Frame-to-frame messages sent by a given participant are *only* visible by\n that same participant. To send messages or state to other participants,\n learn how to [share add-on\n state](/workspace/meet/add-ons/guides/collaborate-in-the-add-on#collaboration).\n\n- Message delivery is only attempted once. To receive messages, the receiving\n panel must be open and the app must subscribe to the callback before the\n message is sent.\n\nRelated topics\n--------------\n\n- [Implement the Co-Doing API](/workspace/meet/add-ons/guides/use-CoDoingAPI)"]]