Ejemplo n.º 1
0
        public void Init()
        {
            Debug.Log("SocialSync.Init");

            _coroutineFactory  = GameApplication.Instance.CoroutineFactory;
            _connectionHandler = new ConnectionHandler();
            _connectionHandler.Init(gameDB, _coroutineFactory);
            _loggerModule = CoreLogger.RegisterModule(GetType().Name);

            SocialStateData socialData = socialStateModel.GetState();

            _socialConnectionStatus = new Dictionary <SocialNetwork, bool>();
            _socialConnectionStatus.Add(SocialNetwork.Facebook, (socialData.facebookId != ""));
            _socialConnectionStatus.Add(SocialNetwork.GameCenter, (socialData.gameCenterId != ""));
            _socialConnectionStatus.Add(SocialNetwork.PlayServices, (socialData.googlePlayId != ""));
            _socialUserId = new Dictionary <SocialNetwork, string>();
            _socialUserId.Add(SocialNetwork.Facebook, socialData.facebookId);
            _socialUserId.Add(SocialNetwork.GameCenter, socialData.gameCenterId);
            _socialUserId.Add(SocialNetwork.PlayServices, socialData.googlePlayId);

            Data.DataElement connConfig = GameApplication.GetConfiguration("connection");
            if (!connConfig.IsNull)
            {
                _fakeFacebookId     = (!connConfig.ContainsKey(_configKeyFakeFacebookId)) ? "0" : (string)connConfig[_configKeyFakeFacebookId];
                _fakeGameCenterId   = (!connConfig.ContainsKey(_configKeyFakeGameCenterId)) ? "0" : (string)connConfig[_configKeyFakeGameCenterId];
                _fakePlayServicesId = (!connConfig.ContainsKey(_configKeyFakePlayServicesId)) ? "0" : (string)connConfig[_configKeyFakePlayServicesId];
            }
        }
Ejemplo n.º 2
0
        public void Init(IGameDB gameDB, ICoroutineFactory coroutineFactory)
        {
            _gameDB           = gameDB;
            _coroutineFactory = coroutineFactory;

            _emptyBody = _encoding.GetBytes(" ");

            Data.DataElement connConfig = GameApplication.GetConfiguration("connection");
            _url = (connConfig.IsNull || !connConfig.ContainsKey(_configKeyURL)) ? _defaultUrl : (string)connConfig[_configKeyURL];

            // TODO - replace this with real versioning mechanism TBD
            string clientVersion = (connConfig.IsNull || !connConfig.ContainsKey(_configKeyClientVersion)) ? "1.0" :
                                   (string)connConfig[_configKeyClientVersion];

            string clientConfigVersion = (connConfig.IsNull || !connConfig.ContainsKey(_configKeyClientConfigVersion)) ? "1.0" :
                                         (string)connConfig[_configKeyClientConfigVersion];

            _headers = new Dictionary <string, string>();
            _headers.Add(_keyToken, "");
            _headers.Add(_keyClientVersion, clientVersion);
            _headers.Add(_keyClientConfigVersion, clientConfigVersion);
            _headers.Add("Content-Length", "1");
        }
Ejemplo n.º 3
0
        public string GetConfigParam(string key)
        {
            string paramValue = (_connConfig.IsNull || !_connConfig.ContainsKey(key)) ? "N/A" : (string)_connConfig[key];

            return(paramValue);
        }
Ejemplo n.º 4
0
        public IPromise TryConnectToServer()
        {
            if (!initialized)
            {
                promise.Dispatch();
                return(promise);
            }

            // Avoid running model sync when uploading gld
            if (IsUploadScene())
            {
                logger.Log(Tag, "Running in upload mode - skipping connection with the server...");
                promise.Dispatch();
                return(promise);
            }


            if (Application.isEditor && !GsdkSettingsData.Instance.IsConnectionEnabled)
            {
                logger.Log(Tag, "Editor Connection is disabled in gsdk settings - will not fetch GLD from the server");
                promise.Dispatch();
                return(promise);
            }

            syncType = SyncType.OnDemand;

            //Load configs
            Data.DataElement connConfig = GameApplication.GetConfiguration("connection");
            string           sType      = (connConfig.IsNull || !connConfig.ContainsKey(SYNC_TYPE_KEY)) ? "Continuous" : (string)connConfig[SYNC_TYPE_KEY];

            syncLoopLength = (connConfig.IsNull || !connConfig.ContainsKey(SYNC_LOOP_KEY)) ? syncLoopLength : (float)connConfig[SYNC_LOOP_KEY];
            bool sEnabled = (connConfig.IsNull || !connConfig.ContainsKey(SYNC_ENABLED_KEY)) ? true : (bool)connConfig[SYNC_ENABLED_KEY];

            if (!sEnabled)
            {
                _dataSyncEnabled = false;
            }

            try
            {
                syncType = (SyncType)Enum.Parse(typeof(SyncType), sType, true);
            } catch (Exception ex)
            {
                logger.LogError(Tag, string.Format("Wrong configuraton in connection config file, the {0} key is not of the type SyncType \n Message received:{1}", SYNC_TYPE_KEY, ex.Message));
            }

            if (syncType != SyncType.Off)
            {
                _coroutineFactory.StartCoroutine(() => WaitForState(SyncLoopState.Connected));
            }

            switch (syncType)
            {
            case SyncType.OnDemand:
                _coroutineFactory.StartCoroutine(() => StartOnDemandMode(false));
                break;

            case SyncType.Continuous:
                _coroutineFactory.StartCoroutine(AsyncLoop);
                break;

            case SyncType.Off:
                promise.Dispatch();
                break;

            default:
                break;
            }

            return(promise);
        }
        public void Init()
        {
            Data.DataElement connConfig = GameApplication.GetConfiguration("connection");

            _bucketId = (connConfig.IsNull || !connConfig.ContainsKey(_configBucketId)) ? "" : (string)connConfig[_configBucketId];
        }