管理用戶端物件
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
本頁面說明如何管理外掛程式與 Google Meet 通訊時所需的用戶端物件。
首先,外掛程式必須建立工作階段:
const session = await window.meet.addon.createAddonSession({
cloudProjectNumber: "CLOUD_PROJECT_NUMBER",
});
將 CLOUD_PROJECT_NUMBER 替換為 Google Cloud 專案的專案編號。
您可以從工作階段建立兩個用戶端物件:
請務必為主要舞台或側邊面板擷取正確的用戶端物件。如果擷取到錯誤的用戶端,Google Meet 外掛程式 SDK 會擲回例外狀況。如要檢查外掛程式在哪個 iframe (主舞台或側邊面板) 中執行,請使用 getFrameType()
方法。
下列程式碼範例說明如何例項化主要階段用戶端物件:
const session = await window.meet.addon.createAddonSession({
cloudProjectNumber: "CLOUD_PROJECT_NUMBER"
});
const mainStageClient = await session.createMainStageClient();
將 CLOUD_PROJECT_NUMBER 替換為 Cloud 專案的專案編號。
共用功能
部分功能適用於 MeetMainStageClient
和 MeetSidePanelClient
物件,其他功能則專用於特定用戶端。
舉例來說,兩個用戶端都支援的功能包括:
客戶專屬功能
僅適用於
MeetMainStageClient
物件的功能:
僅適用於
MeetSidePanelClient
物件的功能:
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2025-08-29 (世界標準時間)。
[null,null,["上次更新時間:2025-08-29 (世界標準時間)。"],[],[],null,["# Manage client objects\n\nThis page describes how to manage client objects that an\nadd-on needs to communicate with Google Meet.\n\nFirst, the add-on needs to establish a session: \n\n const session = await window.meet.addon.createAddonSession({\n cloudProjectNumber: \"\u003cvar translate=\"no\"\u003eCLOUD_PROJECT_NUMBER\u003c/var\u003e\",\n });\n\nReplace \u003cvar translate=\"no\"\u003eCLOUD_PROJECT_NUMBER\u003c/var\u003e with the project number of your\nGoogle Cloud project.\n\nFrom the session, two client objects can be created:\n\n- The [`MeetMainStageClient`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetmainstageclient)\n for an add-on running in the [main\n stage](/workspace/meet/add-ons/guides/overview#main-stage), retrievable using `await\n session.createMainStageClient()`.\n\n- The [`MeetSidePanelClient`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetsidepanelclient)\n for an add-on running in the [side\n panel](/workspace/meet/add-ons/guides/overview#side-panel), retrievable using `await\n session.createSidePanelClient()`.\n\nIt's important to retrieve the correct client object for either the main stage\nor side panel. If the wrong client is retrieved, the Google Meet add-ons SDK throws\nan exception. To check which iframe (main stage or side panel) the\nadd-on is running in, use the\n[`getFrameType()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetaddon.getframetype)\nmethod.\n\nThe following code sample shows how to instantiate the main stage client object: \n\n const session = await window.meet.addon.createAddonSession({\n cloudProjectNumber: \"\u003cvar translate=\"no\"\u003eCLOUD_PROJECT_NUMBER\u003c/var\u003e\"\n });\n const mainStageClient = await session.createMainStageClient();\n\nReplace \u003cvar translate=\"no\"\u003eCLOUD_PROJECT_NUMBER\u003c/var\u003e with the project number of your\nCloud project.\n\nShared features\n---------------\n\nSome features are available in both the `MeetMainStageClient` and the\n`MeetSidePanelClient` object, whereas other features are specific to a certain\nclient.\n\nFor example, some features that are available in both clients include:\n\n- The [`getActivityStartingState()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetaddonclient.getactivitystartingstate) method that gets information about the initial state of the add-on when the participant accepts the invitation to join the activity.\n- The [`getMeetingInfo()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetaddonclient.getmeetinginfo) method that gets details about the meeting in which the add-on is running.\n- The [`setActivityStartingState()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetaddonclient.setactivitystartingstate) method that sets the initial state of the add-on when the participant accepts the invitation to join the activity.\n- For a comprehensive list of features in both clients, see the [`MeetAddonClient`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetaddonclient) object.\n\nClient-specific features\n------------------------\n\nFeatures available only in the\n[`MeetMainStageClient`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetmainstageclient)\nobject:\n\n- The [`notifySidePanel()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetmainstageclient.notifysidepanel)\n method sends a message to the side panel. The message can be received by\n subscribing to the [`frameToFrameMessage`\n callback](/workspace/meet/add-ons/guides/frame-to-frame-messaging) in the side panel.\n\n- The [`loadSidePanel()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetmainstageclient.loadsidepanel)\n method opens the side-panel iframe. The iframe source is set to the\n side-panel URL from the manifest file.\n\n- The [`unloadSidePanel()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetmainstageclient.unloadsidepanel)\n method closes the side-panel iframe. The add-on\n state isn't retained within Meet when the method is called.\n It's up to the add-on to persist any\n add-on state before this method is called.\n\nFeatures available only in the\n[`MeetSidePanelClient`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetsidepanelclient)\nobject:\n\n- The [`notifyMainStage()`](/workspace/meet/add-ons/reference/websdk/addon_sdk.meetsidepanelclient.notifymainstage) method sends a message to the mainStage. The message can be received by subscribing to the [`frameToFrameMessage` callback\n property](/workspace/meet/add-ons/guides/frame-to-frame-messaging) in the mainstage."]]