透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Google Play 遊戲 C++ SDK
摘要
機構
Play 遊戲服務功能的主要進入點是 GameServices 類別。GameServices 執行個體是使用 GameServices::Builder 所建立。請參閱 GameServices
存取或變更整個 GameServices 工作階段狀態的方法,位於 GameServices 類別本身中。
其他功能則是由一組功能的管理員負責提供。這些管理員會將相關的功能集結在一起,本身並不包括使用者看得到的狀態。管理員會透過參照方式傳回,並且由包含的 GameServices 執行個體控制生命週期。因此,用戶端程式碼不應保留管理員參照,而是保留 GameServices 執行個體。請參閱管理員。
透過不可變動的值類型物件傳回資料。這些值反映了查詢當下的基礎資料檢視畫面。請參閱值類型。
執行緒模型
除非另有註明,否則所有 GameServices 方法和 Manager 方法都是執行緒安全和非同步的。開發人員可在不鎖定外部鎖定的執行緒上呼叫這些函式,這些函式會按照叫用順序執行。一般而言,變換器方法 (會改變狀態) 使用射後不理模型。存取子方法 (讀取狀態的方法) 分為兩種主要變化版本。第一個變化版本 (名稱如 GetProperty) 會以非同步方式為提供的回呼提供結果,第二個變化版本 (名稱如 GetPropertyBlocking) 也會同步將結果傳回呼叫執行緒。存取者會看到先前呼叫的所有變異器結果;不過,更動子不一定能隨時修改遠端遊戲服務狀態。
所有使用者回呼 (無論是做為存取子方法的引數,或在 GameServices 建構時間設定的多重用途回呼) 都會透過專屬的回呼執行緒叫用。這個執行緒可能與「主執行緒」或「UI 執行緒」的任何平台概念不同。使用者回呼應快速執行,因為延遲回呼執行緒可能會導致使用者明顯出現問題 (例如延遲完成登出要求)。
不可變動值類型的屬性可同步使用,而不會進行封鎖。
這個頁面中的內容和程式碼範例均受《內容授權》中的授權所規範。Java 與 OpenJDK 是 Oracle 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],null,["# Google Play Games C++ SDK\n=========================\n\nSummary\n-------\n\nOrganization\n\nThe main entry point for Play Game Services functionality is the GameServices class. GameServices instances are created with GameServices::Builder. See [GameServices](/games/services/cpp/api/other/classgpg_1_1GameServices)\n\nMethods that access or mutate the state of the entire GameServices session live in the GameServices class itself.\n\nOther functionality is indirected through a set of per-feature managers. These managers group related functionality together; they contain no user-visible state themselves. Managers are returned by reference, and have lifetime controlled by the containing GameServices instance. As such, client code should never hold onto a manager reference, but instead hold on to the GameServices instance. See [Managers](/games/services/cpp/api/other/group__Managers).\n\nData is returned via immutable value type objects. These values reflect a consistent view of the underlying data at the point in time the query was made. See [Value Types](/games/services/cpp/api/other/group__ValueType).\n\nThreading Model\n\nUnless otherwise noted, all GameServices methods and Manager methods are threadsafe and asynchronous. They can be called on any thread without external locking, and will execute in an order consistent with their invocation order. In general, mutator methods (those that change state) use a fire-and-forget model. Accessor methods (those that read state) come in two major variants. The first variant (with names like GetProperty) asynchronously supply their results to a provided callback; the second variant (with names like GetPropertyBlocking) synchronously return their results to the calling thread. Accessors see the results of all mutators that have been called prior; however, the mutator may or may not have modified the remote Game Services state at any given time.\n\nAll user callbacks (whether one-shot callbacks supplied as arguments to accessor methods, or multi-use callbacks configured at GameServices build time) are invoked on a dedicated callback thread. This thread is potentially distinct from any platform concept of a \"main thread\" or \"UI thread\". User callbacks should execute quickly, as a stalled callback thread can cause user-visible issues (for example, delayed completion of a sign-out request).\n\nProperties on immutable value types are available synchronously and without blocking."]]