Ejemplo n.º 1
0
 internal void MessageReceived(SyncFileMessage message)
 {
     if (message.Type == SyncFileMessageType.Connect)
     {
         var d  = message.ClientData.GetSerializeAble <SyncFileData>();
         var sf = new SyncFile();
         sf.Task            = new FileTransportTask();
         sf.Task.ID         = message.TaskID;
         sf.Task.Size       = d.Size;
         sf.Manager         = this;
         sf.SendData        = false;
         sf.AccessID        = d.AccessID;
         sf.OwnerID         = message.OwnerID;
         sf.Task.TargetUser = Manager.Users.GetUserFromId(message.MessageRoot.RemoteId);
         Files.Add(sf);
         sf.SendInfo(SyncFileMessageType.ConnectionSuccess, null);
         if (SyncFileAdded != null)
         {
             SyncFileAdded(this, sf);
         }
     }
     else
     {
         var file = Files.Find((sf) =>
         {
             if (message.TaskID != sf.Task.ID)
             {
                 return(false);
             }
             if (message.OwnerID.Length != sf.OwnerID.Length)
             {
                 return(false);
             }
             for (int i = 0; i < message.OwnerID.Length; ++i)
             {
                 if (message.OwnerID[i] != sf.OwnerID[i])
                 {
                     return(false);
                 }
             }
             return(true);
         });
         if (message.Type == SyncFileMessageType.ConnectionSuccess)
         {
             FileTransport.StartTask(file.Task);
         }
     }
 }
Ejemplo n.º 2
0
        public SyncFile Syncronize(User TargetUser, byte[] Data, int AccessID)
        {
            var sf = new SyncFile();
            var t  = sf.Task = new FileTransportTask();

            t.Data       = Data;
            t.Size       = Data.Length;
            t.TargetUser = TargetUser;
            sf.OwnerID   = Manager.CurrentId.Id;
            sf.Manager   = this;
            sf.SendData  = true;
            sf.AccessID  = AccessID;
            Files.Add(sf);
            sf.SetEvents();
            sf.Send();
            return(sf);
        }
Ejemplo n.º 3
0
        public SyncFile Syncronize(User TargetUser, int DatasetCount, GetFileData getDataHandler, int AccessId)
        {
            var sf = new SyncFile();
            var t  = sf.Task = new FileTransportTask();

            t.DatasetCount    = DatasetCount;
            t.Size            = DatasetCount;
            t.GetDatasetData += getDataHandler;
            t.TargetUser      = TargetUser;
            sf.OwnerID        = Manager.CurrentId.Id;
            sf.Manager        = this;
            sf.SendData       = true;
            sf.AccessID       = AccessId;
            Files.Add(sf);
            sf.SetEvents();
            sf.Send();
            return(sf);
        }