Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Pakiet SDK C++ dla Gier Google Play
Podsumowanie
Organizacja
Głównym punktem wejścia do funkcji usług gier Play jest klasa GameServices. Instancje GameServices są tworzone za pomocą GameServices::Builder. Zobacz GameServices
Metody, które uzyskują dostęp do stanu całej sesji GameServices lub zmieniają stan całej sesji GameServices, znajdują się w samej klasie GameServices.
Inne funkcje są kierowane do odpowiednich menedżerów funkcji. Menedżerowie ci grupują powiązane funkcje, ale nie mają stanu widocznego dla użytkowników. Menedżerowie są zwracani przez odwołanie, a ich czas przechowywania jest kontrolowany przez instancję GameServices. W związku z tym kod klienta nie powinien zawierać odwołania do menedżera, ale powinien należeć do instancji GameServices. Zobacz sekcję Menedżerowie.
Dane są zwracane przez obiekty typu wartości stałego. Wartości te odzwierciedlają spójny widok danych bazowych w momencie przesłania zapytania. Zobacz Typy wartości.
Model z gwintowaniem
O ile nie wskazano inaczej, wszystkie metody GameServices i metody menedżera są bezpieczne w wątkach i asynchroniczne. Można je wywoływać w dowolnym wątku bez blokady zewnętrznego i uruchamiać w kolejności zgodnej z kolejnością ich wywoływania. Ogólnie metody mutatora (te, które zmieniają stan) korzystają z modelu „wypal i zapomnij”. Metody dostępu (czyli te, które odczytują stan) występują w 2 głównych wariantach. Pierwszy wariant (o nazwach takich jak GetProperty) asynchronicznie dostarcza wyniki do podanego wywołania zwrotnego. Drugi (o nazwach takich jak GetPropertyblok) synchronicznie zwraca wyniki do wątku wywołującego. Uzyskujący dostęp widzą wyniki wszystkich mutatorów, które zostały wywołane wcześniej, ale mogli, ale nie muszą, w dowolnym momencie zmodyfikować stan zdalnych usług gier.
Wszystkie wywołania zwrotne użytkownika (niezależnie od tego, czy wywołania zwrotne są podane jako argumenty metod akcesora czy wielokrotne wywołania skonfigurowane w czasie kompilacji GameServices) są wywoływane w dedykowanym wątku wywołania zwrotnego. Ten wątek może różnić się od koncepcji „głównego wątku” lub „wątku interfejsu użytkownika” na danej platformie. Wywołania zwrotne użytkowników powinny być wykonywane szybko, ponieważ opóźniony wątek wywołania zwrotnego może powodować problemy widoczne dla użytkowników (na przykład opóźnione zakończenie żądania wylogowania).
Właściwości stałych typów wartości są dostępne synchronicznie i bez blokowania.
Treść strony i umieszczone na niej fragmenty kodu podlegają licencjom opisanym w Licencji na treści. Java i OpenJDK są znakami towarowymi lub zastrzeżonymi znakami towarowymi należącymi do firmy Oracle lub jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-07-27 UTC.
[[["Łatwo zrozumieć","easyToUnderstand","thumb-up"],["Rozwiązało to mój problem","solvedMyProblem","thumb-up"],["Inne","otherUp","thumb-up"]],[["Brak potrzebnych mi informacji","missingTheInformationINeed","thumb-down"],["Zbyt skomplikowane / zbyt wiele czynności do wykonania","tooComplicatedTooManySteps","thumb-down"],["Nieaktualne treści","outOfDate","thumb-down"],["Problem z tłumaczeniem","translationIssue","thumb-down"],["Problem z przykładami/kodem","samplesCodeIssue","thumb-down"],["Inne","otherDown","thumb-down"]],["Ostatnia aktualizacja: 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."]]