Example #1
0
        public void PullTest()
        {
            AdbConnection connect     = CreateAdbConnection();
            SyncSession   syncSession = connect.OpenSync();

            syncSession.Pull("/data/test.log", new FileInfo("test.log"));
            syncSession.Close();

            connect.Close();
        }
 private void syncAdatapersAssertNoConflicts(BookRepositorySyncableStoreAdapter adapter1, BookRepositorySyncableStoreAdapter adapter2)
 {
     // send any changes in 1 to cloud
     using (var connection = GetServerConnection())
     {
         var session1   = new SyncSession(adapter1, new ClientSyncSessionDbConnectionProdivder(), new DirectSyncTransport(adapter2, connection));
         var conflicts1 = session1.SyncWithRemoteAsync().Result;
         Assert.AreEqual(0, conflicts1.Count());
         session1.Close();
     }
     File.Delete("ServerSession.sqlite");
 }
Example #3
0
        public void PushTest()
        {
            using (AdbConnection connect = CreateAdbConnection())
            {
                SyncSession syncSession = connect.OpenSync();
                File.WriteAllText("test.log", "aaaa");
                syncSession.Push("/data/test.log", new FileInfo("test.log"));
                syncSession.Close();

                connect.Close();
            }
        }
Example #4
0
        private async void syncButton_Click(object sender, RoutedEventArgs e)
        {
            syncButton.IsEnabled = false;
            using (var adapter = new BookRepositorySyncableStoreAdapter(_repos))
            {
                var session         = new SyncSession(adapter, new ClientSyncSessionDbConnectionProdivder(), new HttpSyncTransport(new Uri("http://*****:*****@example.com", "monkey"));
                var progressWatcher = new Progress <SyncProgress>(reportProgress);
                await session.SyncWithRemoteAsync(progressWatcher, CancellationToken.None);

                session.Close();
            }
            syncButton.IsEnabled = true;
        }
        public static void SendMsg(this SyncSession session, string key, Dictionary <string, object> data)
        {
            if (session == null)
            {
                //Debug.LogError("Session 已经断开连接!");
                return;
            }

            ByteArray ba = new ByteArray();

            List <byte> message = GetSendByte(key, data);

            int len    = 3 + message.Count;
            int method = GetMethodIndex(key);

            ba.WriteShort(len);
            ba.WriteByte((byte)(method / 100));
            ba.WriteShort(method);

            if (message != null)
            {
                ba.bytes.AddRange(message);
            }
            else
            {
                ba.WriteInt(0);
            }

            byte[] buffer = ba.Buffer;

            //Debug.Log("消息头 " + method + " 消息名 " + key + " --> " + BitConverter.ToString(buffer));

            try
            {
                int  time   = ServiceTime.GetServiceTime();
                bool result = session.TrySend(buffer, 0, buffer.Length);
                if (!result)
                {
                    session.Close();
                }

                if (ServiceTime.GetServiceTime() - time > 10)
                {
                    Debug.Log("发送时间 " + (ServiceTime.GetServiceTime() - time));
                }
            }
            catch (Exception e)
            {
                Debug.LogError("Send Messge Exception " + e.ToString());
            }
        }
Example #6
0
        public static void Send(this SyncSession session, ProtocolRequestBase msg)
        {
            ByteArray ba = new ByteArray();

            ba.bytes.AddRange(GetSendByte(msg.Key, msg.m_data));

            byte[] buffer = ba.Buffer;

            bool result = session.TrySend(buffer, 0, buffer.Length);

            if (!result)
            {
                session.Close();
            }
        }