本文整理汇总了C#中Couchbase.Lite.Replication.Start方法的典型用法代码示例。如果您正苦于以下问题:C# Replication.Start方法的具体用法?C# Replication.Start怎么用?C# Replication.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Couchbase.Lite.Replication
的用法示例。
在下文中一共展示了Replication.Start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateReplications
private void UpdateReplications(string syncURL)
{
if (_puller != null)
{
_puller.Stop();
}
if(_pusher != null)
{
_pusher.Stop();
}
if (String.IsNullOrEmpty(syncURL))
{
return;
}
var uri = new Uri(syncURL);
_puller = _db.CreatePullReplication(uri);
_puller.Continuous = true;
_puller.Start();
_pusher = _db.CreatePushReplication(uri);
_pusher.Continuous = true;
_pusher.Start();
}
示例2: Start
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();
}
示例3: StartSync
public void StartSync(string syncUrl)
{
Uri uri;
try {
uri = new Uri(syncUrl);
} catch(UriFormatException) {
Log.E("TaskManager", "Invalid URL {0}", syncUrl);
return;
}
if(_pull == null) {
_pull = _db.CreatePullReplication(uri);
_pull.Continuous = true;
_pull.Start();
}
if(_push == null) {
_push = _db.CreatePushReplication(uri);
_push.Continuous = true;
_push.Start();
}
}
示例4: RunReplication
private void RunReplication(Replication replication)
{
var replicationDoneSignal = new CountDownLatch(1);
var observer = new ReplicationObserver(replicationDoneSignal);
replication.Changed += observer.Changed;
replication.Start();
var replicationDoneSignalPolling = ReplicationWatcherThread(replication);
Log.D(Tag, "Waiting for replicator to finish.");
var success = replicationDoneSignal.Await(TimeSpan.FromSeconds(15));
Assert.IsTrue(success);
success = replicationDoneSignalPolling.Wait(TimeSpan.FromSeconds(15));
Assert.IsTrue(success);
Log.D(Tag, "replicator finished");
replication.Changed -= observer.Changed;
}
示例5: DoReplication
IEnumerator DoReplication(Replication replication)
{
replication.Start ();
while (replication != null && replication.Status == ReplicationStatus.Active) {
yield return new WaitForSeconds(0.5f);
}
}
示例6: UpdateSyncUrl
void UpdateSyncUrl ()
{
if (Database == null)
return;
Uri newRemoteUrl = null;
var syncPoint = NSUserDefaults.StandardUserDefaults.StringForKey (ConfigViewController.SyncUrlKey);
if (!String.IsNullOrWhiteSpace (syncPoint))
newRemoteUrl = new Uri (syncPoint);
else
return;
ForgetSync ();
pull = Database.CreatePullReplication (newRemoteUrl);
push = Database.CreatePushReplication (newRemoteUrl);
pull.Continuous = push.Continuous = true;
pull.Changed += ReplicationProgress;
push.Changed += ReplicationProgress;
pull.Start();
push.Start();
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-couchbase-lite-net-couchbase,代码行数:21,代码来源:RootViewController.cs
示例7: RunReplication
protected virtual void RunReplication(Replication replication)
{
var replicationDoneSignal = new CountdownEvent(1);
var observer = new ReplicationObserver(replicationDoneSignal);
replication.Changed += observer.Changed;
replication.Start();
var success = replicationDoneSignal.Wait(TimeSpan.FromSeconds(60));
Assert.IsTrue(success);
replication.Changed -= observer.Changed;
}
示例8: RunReplication
private void RunReplication(Replication replication)
{
CountDownLatch replicationDoneSignal = new CountDownLatch(1);
ReplicationTest.ReplicationObserver replicationObserver = new ReplicationTest.ReplicationObserver
(this, replicationDoneSignal);
replication.AddChangeListener(replicationObserver);
replication.Start();
CountDownLatch replicationDoneSignalPolling = ReplicationWatcherThread(replication
);
Log.D(Tag, "Waiting for replicator to finish");
try
{
bool success = replicationDoneSignal.Await(300, TimeUnit.Seconds);
NUnit.Framework.Assert.IsTrue(success);
success = replicationDoneSignalPolling.Await(300, TimeUnit.Seconds);
NUnit.Framework.Assert.IsTrue(success);
Log.D(Tag, "replicator finished");
}
catch (Exception e)
{
Sharpen.Runtime.PrintStackTrace(e);
}
}
示例9: RunReplication
protected override void RunReplication(Replication replication)
{
var replicationDoneSignal = new CountdownEvent(1);
var observer = new ReplicationObserver(replicationDoneSignal);
replication.Changed += observer.Changed;
replication.Start();
var replicationDoneSignalPolling = ReplicationWatcherThread(replication);
var success = replicationDoneSignal.Wait(TimeSpan.FromSeconds(15));
Assert.IsTrue(success);
success = replicationDoneSignalPolling.Wait(TimeSpan.FromSeconds(15));
Assert.IsTrue(success);
replication.Changed -= observer.Changed;
}
示例10: StartPushChanges
void StartPushChanges()
{
string uri = "http://" + hostName + ":" + portNumber.ToString() + "/" + databaseName;
pushReplication = database.CreatePushReplication (new Uri (uri));
pushReplication.Start ();
}
示例11: StartReplication
void StartReplication ()
{
if (StringEx.IsNullOrWhiteSpace (replicationUrl)) {
Log.E (TAG, "Replication URL not set");
return;
}
_puller = _db.CreatePullReplication (new Uri(replicationUrl));
_puller.Continuous = true;
_puller.Changed += (sender, e) => {
Log.D (TAG, "Puller: " + _puller.LastError == null ? "Okay" : _puller.LastError.Message);
};
_pusher = _db.CreatePushReplication (new Uri(replicationUrl));
_pusher.Continuous = true;
_pusher.Changed += (sender, e) => {
Log.D (TAG, "Pusher: " + _pusher.LastError == null ? "Okay" : _pusher.LastError.Message);
};
_pusher.Start ();
_puller.Start ();
Log.D (TAG, "Started replication with " + replicationUrl);
}
示例12: RunReplication
private void RunReplication(Replication replication)
{
// var replicationDoneSignal = new CountDownLatch(1);
var replicationDoneSignalPolling = ReplicationWatcherThread(replication);
replication.Changed += (sender, e) =>
replicationDoneSignalPolling.CountDown ();
replication.Start();
Log.D(Tag, "Waiting for replicator to finish");
try
{
var success = replicationDoneSignalPolling.Await(TimeSpan.FromSeconds(15));
Assert.IsTrue(success);
Sharpen.Thread.Sleep(5000);
replication.Stop();
Log.D(Tag, "replicator finished");
}
catch (Exception e)
{
Runtime.PrintStackTrace(e);
}
}
示例13: UpdateSync
private void UpdateSync()
{
if (Database == null)
return;
var preferences = PreferenceManager.GetDefaultSharedPreferences(this);
var syncUrl = preferences.GetString("sync-gateway-url", null);
ForgetSync ();
if (!String.IsNullOrEmpty(syncUrl))
{
try
{
var uri = new System.Uri(syncUrl);
Pull = Database.CreatePullReplication(uri);
Pull.Continuous = true;
Pull.Changed += ReplicationChanged;
Push = Database.CreatePushReplication(uri);
Push.Continuous = true;
Push.Changed += ReplicationChanged;
Pull.Start();
Push.Start();
}
catch (Java.Lang.Throwable th)
{
Log.Debug(Tag, th, "UpdateSync Error");
}
}
}
示例14: StartSyncGateway
public void StartSyncGateway(string url = "")
{
pull = _database.CreatePullReplication(CreateSyncUri());
push = _database.CreatePushReplication(CreateSyncUri());
var authenticator = AuthenticatorFactory.CreateBasicAuthenticator("david", "12345");
pull.Authenticator = authenticator;
push.Authenticator = authenticator;
pull.Continuous = true;
push.Continuous = true;
pull.Changed += Pull_Changed;
push.Changed += Push_Changed;
pull.Start();
push.Start();
}
示例15: TestIssue490
public void TestIssue490()
{
var sg = new CouchDB("http", GetReplicationServer());
using (var remoteDb = sg.CreateDatabase("issue490")) {
var push = database.CreatePushReplication(remoteDb.RemoteUri);
CreateFilteredDocuments(database, 30);
CreateNonFilteredDocuments (database, 10);
RunReplication(push);
Assert.IsTrue(push.ChangesCount==40);
Assert.IsTrue(push.CompletedChangesCount==40);
Assert.IsNull(push.LastError);
Assert.AreEqual(40, database.DocumentCount);
for (int i = 0; i <= 5; i++) {
pull = database.CreatePullReplication(remoteDb.RemoteUri);
pull.Continuous = true;
pull.Start ();
Task.Delay (1000).Wait();
CallToView ();
Task.Delay (2000).Wait();
RecreateDatabase ();
}
}
}