Start() public method

public Start ( ) : void
return void
Ejemplo n.º 1
0
        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 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");
                }
            }
        }
Ejemplo n.º 2
0
        private static void PullRepBroker()
        {
            var tasksToSend       = new List <CommonRequest>();
            var responsesToClient = new List <CommonReply>();

            Pull <CommonRequest>             pull = null;
            REP <CommonRequest, CommonReply> rep  = null;

            var processClientRequest = new Func <CommonRequest, bool>(r =>
            {
                Console.WriteLine("[x] Received request {0} from {1} ", r.RequestId, r.ClientId.ToString().Substring(30));

                tasksToSend.Add(r);
                rep.AddTask(r);
                return(true);
            });

            var fromClientTask = Task.Factory.StartNew(() =>
            {
                pull = new Pull <CommonRequest>("tcp://127.0.0.1:5001", processClientRequest);
                pull.Start();
            });

            var processWorkerResponse = new Func <CommonReply, bool>(r =>
            {
                Console.WriteLine("[x] Received reply {0} to {1} ", r.ReplyId, r.ClientId.ToString().Substring(30));

                if (r.ClientId != default(Guid))
                {
                    responsesToClient.Add(r);
                }

                // TODO: Send response to client

                return(true);
            });

            var toWorkerTask = Task.Factory.StartNew(() =>
            {
                rep = new REP <CommonRequest, CommonReply>("tcp://127.0.0.1:5000", processWorkerResponse);
                rep.Start();
            });

            Task.WaitAll(fromClientTask, toWorkerTask);
        }
Ejemplo n.º 3
0
 public void Start(Action <string> handleAction)
 {
     _pull = new Pull <string>("tcp://127.0.0.1:5052", handleAction);
     _pull.Start();
 }