private void InitializeGameServices() { lock (GameServicesLock) { if (mServices != null) { return; } using (var builder = GameServicesBuilder.Create()) { using (var config = CreatePlatformConfiguration(builder)) { builder.SetOnAuthFinishedCallback(HandleAuthTransition); builder.SetOnTurnBasedMatchEventCallback((eventType, matchId, match) => mTurnBasedClient.HandleMatchEvent(eventType, matchId, match)); builder.SetOnMultiplayerInvitationEventCallback(HandleInvitation); mServices = builder.Build(config); mTurnBasedClient = new NativeTurnBasedMultiplayerClient(this, new TurnBasedManager(mServices)); mRealTimeClient = new NativeRealtimeMultiplayerClient(this, new RealtimeManager(mServices)); mAppStateClient = CreateAppStateClient(); mAuthState = AuthState.SilentPending; } } } }
private void InitializeGameServices() { lock (GameServicesLock) { if (mServices != null) { return; } using (var builder = GameServicesBuilder.Create()) { using (var config = CreatePlatformConfiguration()) { // We need to make sure that the invitation delegate is registered before the // services object is initialized - otherwise we might miss a callback if // the game was opened because of a user accepting an invitation through // a system notification. RegisterInvitationDelegate(mConfiguration.InvitationDelegate); builder.SetOnAuthFinishedCallback(HandleAuthTransition); builder.SetOnTurnBasedMatchEventCallback((eventType, matchId, match) => mTurnBasedClient.HandleMatchEvent(eventType, matchId, match)); builder.SetOnMultiplayerInvitationEventCallback(HandleInvitation); if (mConfiguration.EnableSavedGames) { builder.EnableSnapshots(); } mServices = builder.Build(config); mEventsClient = new NativeEventClient(new EventManager(mServices)); mQuestsClient = new NativeQuestClient(new QuestManager(mServices)); mTurnBasedClient = new NativeTurnBasedMultiplayerClient(this, new TurnBasedManager(mServices)); mTurnBasedClient.RegisterMatchDelegate(mConfiguration.MatchDelegate); mRealTimeClient = new NativeRealtimeMultiplayerClient(this, new RealtimeManager(mServices)); if (mConfiguration.EnableSavedGames) { mSavedGameClient = new NativeSavedGameClient(new SnapshotManager(mServices)); } else { mSavedGameClient = new UnsupportedSavedGamesClient( "You must enable saved games before it can be used. " + "See PlayGamesClientConfiguration.Builder.EnableSavedGames."); } mAppStateClient = CreateAppStateClient(); mAuthState = AuthState.SilentPending; } } } }
public void Setup(GameHelperListener listener, int clientsToUse) { this.listener = listener; requestClients = clientsToUse; List <string> scopesList = new List <string>(); if (0 != (clientsToUse & CLIENT_GAMES)) { scopesList.Add(Scopes.Games); } if (0 != (clientsToUse & CLIENT_PLUS)) { scopesList.Add(Scopes.PlusLogin); } if (0 != (clientsToUse & CLIENT_APPSTATE)) { scopesList.Add(Scopes.AppState); } if (0 != (clientsToUse & CLIENT_GAMES)) { gamesClient = new GamesClient.Builder(activity, this, this) .SetGravityForPopups((int)(GravityFlags.Top | GravityFlags.CenterHorizontal)) .SetScopes(scopesList.ToArray()) .Create(); } if (0 != (clientsToUse & CLIENT_PLUS)) { plusCient = new PlusClient.Builder(activity, this, this) .SetScopes(scopesList.ToArray()) .Build(); } if (0 != (clientsToUse & CLIENT_APPSTATE)) { appStateClient = new AppStateClient.Builder(activity, this, this) .SetScopes(scopesList.ToArray()) .Create(); } }
private void InitializeGameServices() { lock (GameServicesLock) { if (mServices != null) { return; } using (var builder = GameServicesBuilder.Create()) { using (var config = CreatePlatformConfiguration(builder)) { // We need to make sure that the invitation delegate is registered before the // services object is initialized - otherwise we might miss a callback if // the game was opened because of a user accepting an invitation through // a system notification. RegisterInvitationDelegate(mConfiguration.InvitationDelegate); builder.SetOnAuthFinishedCallback(HandleAuthTransition); builder.SetOnTurnBasedMatchEventCallback((eventType, matchId, match) => mTurnBasedClient.HandleMatchEvent(eventType, matchId, match)); builder.SetOnMultiplayerInvitationEventCallback(HandleInvitation); if (mConfiguration.EnableSavedGames) { builder.EnableSnapshots(); } mServices = builder.Build(config); mTurnBasedClient = new NativeTurnBasedMultiplayerClient(this, new TurnBasedManager(mServices)); mTurnBasedClient.RegisterMatchDelegate(mConfiguration.MatchDelegate); mRealTimeClient = new NativeRealtimeMultiplayerClient(this, new RealtimeManager(mServices)); if (mConfiguration.EnableSavedGames) { mSavedGameClient = new NativeSavedGameClient(new SnapshotManager(mServices)); } else { mSavedGameClient = new UnsupportedSavedGamesClient( "You must enable saved games before it can be used. " + "See PlayGamesClientConfiguration.Builder.EnableSavedGames."); } mAppStateClient = CreateAppStateClient(); mAuthState = AuthState.SilentPending; } } } }
public void Setup(GameHelperListener listener, int clientsToUse) { this.listener = listener; requestClients = clientsToUse; List<string> scopesList = new List<string>(); if (0 != (clientsToUse & CLIENT_GAMES)) { scopesList.Add(Scopes.Games); } if (0 != (clientsToUse & CLIENT_PLUS)) { scopesList.Add(Scopes.PlusLogin); } if (0 != (clientsToUse & CLIENT_APPSTATE)) { scopesList.Add(Scopes.AppState); } if (0 != (clientsToUse & CLIENT_GAMES)) { gamesClient = new GamesClient.Builder(activity, this, this) .SetGravityForPopups((int)(GravityFlags.Top | GravityFlags.CenterHorizontal)) .SetScopes(scopesList.ToArray()) .Create(); } if (0 != (clientsToUse & CLIENT_PLUS)) { plusCient = new PlusClient.Builder(activity, this, this) .SetScopes(scopesList.ToArray()) .Build(); } if (0 != (clientsToUse & CLIENT_APPSTATE)) { appStateClient = new AppStateClient.Builder(activity, this, this) .SetScopes(scopesList.ToArray()) .Create(); } }