프레임 간 메시지 사용
이 페이지에서는 클라이언트 측에서 측면 패널 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 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 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"]]