Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
SDK C++ Google Play Game
Ringkasan
Organisasi
Titik entri utama untuk fungsi Layanan game Play adalah class GameServices. Instance GameServices dibuat dengan GameServices::Builder. Lihat GameServices
Metode yang mengakses atau mengubah status seluruh sesi GameServices berada di class GameServices itu sendiri.
Fungsi lainnya dialihkan melalui serangkaian pengelola per fitur. Pengelola ini mengelompokkan fungsi terkait; pengelola ini tidak berisi status yang terlihat oleh pengguna. Pengelola ditampilkan oleh referensi, dan memiliki masa aktif yang dikontrol oleh instance GameServices yang memuatnya. Dengan demikian, kode klien tidak boleh menyimpan referensi pengelola, tetapi menyimpan instance GameServices. Lihat Pengelola.
Data ditampilkan melalui objek jenis nilai yang tidak dapat diubah. Nilai ini mencerminkan tampilan yang konsisten atas data pokok pada waktu ketika kueri dibuat. Lihat Jenis Nilai.
Model Threading
Kecuali jika dinyatakan lain, semua metode GameServices dan metode Pengelola aman untuk thread dan asinkron. Metode ini dapat dipanggil pada thread apa pun tanpa penguncian eksternal, dan akan dijalankan dalam urutan yang konsisten dengan urutan pemanggilannya. Secara umum, metode pengubah (yang mengubah status) menggunakan model fire-and-forget. Metode aksesor (yang membaca status) terdiri dalam dua varian utama. Varian pertama (dengan nama seperti GetProperty) secara asinkron menyediakan hasilnya ke callback yang disediakan; varian kedua (dengan nama seperti GetPropertyBlocking) secara sinkron menampilkan hasilnya ke thread yang melakukan panggilan. Pengakses melihat hasil dari semua pengubah yang telah dipanggil sebelumnya; namun, pengubah mungkin telah atau belum mengubah status Layanan game jarak jauh pada waktu tertentu.
Semua callback pengguna (baik callback one-shot yang disediakan sebagai argumen ke metode pengakses, maupun callback multi-penggunaan yang dikonfigurasi pada waktu build GameServices) dipanggil pada thread callback khusus. Thread ini berpotensi berbeda dengan konsep platform apa pun tentang "thread utama" atau "thread UI". Callback pengguna harus dijalankan dengan cepat, karena thread callback yang macet dapat menyebabkan masalah yang terlihat oleh pengguna (misalnya keterlambatan penyelesaian permintaan logout).
Properti pada jenis nilai yang tidak dapat diubah tersedia secara sinkron dan tanpa pemblokiran.
Konten dan contoh kode di halaman ini tunduk kepada lisensi yang dijelaskan dalam Lisensi Konten. Java dan OpenJDK adalah merek dagang atau merek dagang terdaftar dari Oracle dan/atau afiliasinya.
Terakhir diperbarui pada 2025-07-27 UTC.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Informasi yang saya butuhkan tidak ada","missingTheInformationINeed","thumb-down"],["Terlalu rumit/langkahnya terlalu banyak","tooComplicatedTooManySteps","thumb-down"],["Sudah usang","outOfDate","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Masalah kode / contoh","samplesCodeIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-07-27 UTC."],[],[],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."]]