| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- #include "Base.h"
- #include "SocialController.h"
- #include "Game.h"
- #include "social/ScoreloopSocialSession.h"
- #include "social/GooglePlaySocialSession.h"
- namespace gameplay
- {
- SocialController::SocialController()
- : _session(NULL)
- {
- }
- SocialController::~SocialController()
- {
- }
- void SocialController::initialize()
- {
- }
- void SocialController::finalize()
- {
- if (_session)
- _session->synchronizeAchievements();
- }
- void SocialController::pause()
- {
- if (_session)
- _session->synchronizeAchievements();
- }
- void SocialController::resume()
- {
- }
- void SocialController::update(float elapsedTime)
- {
- }
- bool SocialController::handleEvent(void *event)
- {
- if (_session)
- return _session->handleEvent(event);
- return false;
- }
- void SocialController::authenticate(SocialSessionListener* listener)
- {
- #ifdef GP_USE_SOCIAL
- #if defined(__QNX__)
- Properties* socialProperties = Game::getInstance()->getConfig()->getNamespace("social", true);
- const char* providerStr = "";
- if (socialProperties)
- {
- providerStr = socialProperties->getString("provider");
- }
- if (strcmp(providerStr, "Scoreloop") == 0)
- {
- _session = ScoreloopSocialSession::authenticate(listener, socialProperties);
- }
- else
- {
- listener->authenticateEvent(SocialSessionListener::ERROR_INITIALIZATION, NULL);
- }
- #elif defined(__ANDROID__)
- Properties* socialProperties = Game::getInstance()->getConfig()->getNamespace("social", true);
- const char* providerStr = "";
- if (socialProperties)
- {
- providerStr = socialProperties->getString("provider");
- }
- if (strcmp(providerStr, "GooglePlay") == 0)
- {
- _session = GoogleGamesSocialSession::authenticate(listener, socialProperties);
- }
- else
- {
- listener->authenticateEvent(SocialSessionListener::ERROR_INITIALIZATION, NULL);
- }
- #endif
- #endif
- }
- }
|