private IEnumerator Start () { Debug.LogFormat ("Data path = {0}", Application.persistentDataPath); #if UNITY_EDITOR_WIN Log.SetLogger(new UnityLogger()); #endif _db = Manager.SharedInstance.GetDatabase ("spaceshooter"); _pull = _db.CreatePullReplication (GameController.SYNC_URL); _pull.Continuous = true; _pull.Start (); while (_pull != null && _pull.Status == ReplicationStatus.Active) { yield return new WaitForSeconds(0.5f); } var doc = _db.GetExistingDocument ("player_data"); if (doc != null) { //We have a record! Get the ship data, if possible. string assetName = String.Empty; if(doc.UserProperties.ContainsKey("ship_data")) { assetName = doc.UserProperties ["ship_data"] as String; } StartCoroutine(LoadAsset (assetName)); } else { //Create a new record doc = _db.GetDocument("player_data"); doc.PutProperties(new Dictionary<string, object> { { "ship_data", String.Empty } }); } doc.Change += DocumentChanged; _push = _db.CreatePushReplication (new Uri ("http://127.0.0.1:4984/spaceshooter")); _push.Start(); }
private Replication CreateReplication(Database db, bool push) { Replication repl = null; if (push) { repl = db.CreatePushReplication(_listenerDBUri); } else { repl = db.CreatePullReplication(_listenerDBUri); } #if USE_AUTH repl.Authenticator = new DigestAuthenticator("bob", "slack"); #endif return(repl); }
private Replication CreateReplication(Database db, bool push) { Replication repl = null; if (push) { repl = db.CreatePushReplication(_listenerDBUri); } else { repl = db.CreatePullReplication(_listenerDBUri); } if (_authScheme == AuthenticationSchemes.Basic) { repl.Authenticator = new BasicAuthenticator("bob", "slack"); } else if (_authScheme == AuthenticationSchemes.Digest) { repl.Authenticator = new DigestAuthenticator("bob", "slack"); } return(repl); }
private Replication CreateReplication(Database db, bool push) { Replication repl = null; if (push) { repl = db.CreatePushReplication(_listenerDBUri); } else { repl = db.CreatePullReplication(_listenerDBUri); } #if USE_AUTH repl.Authenticator = new DigestAuthenticator("bob", "slack"); #endif return repl; }
private Replication CreateReplication(Database db, bool push) { Replication repl = null; if (push) { repl = db.CreatePushReplication(_listenerDBUri); } else { repl = db.CreatePullReplication(_listenerDBUri); } if (_authScheme == AuthenticationSchemes.Basic) { repl.Authenticator = new BasicAuthenticator("bob", "slack"); } else if (_authScheme == AuthenticationSchemes.Digest) { repl.Authenticator = new DigestAuthenticator("bob", "slack"); } return repl; }