Exemple #1
0
 public string ProcessInterest(string interestName, string face)
 {
     try
     {
         PITEntry pITEntry = _pitService.GetPITEntryBy(interestName);
         if (pITEntry != null)
         {
             pITEntry.IncommingFace.Add(face);
             _pitService.EditPITEntry(pITEntry);
         }
         else // PIT does not exist check content store
         {
             ContentStore contentStore = _contentStoreService.GetContentStoreBy(interestName);
             if (contentStore != null)
             {
                 return(contentStore.Content);
             }
             else // content is not in CS
             {
                 FIBEntry fIBEntry = _fibService.GetFIBEntryBy(interestName);
                 ForwardInterest(fIBEntry, interestName);
             }
         }
         return(string.Empty);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #2
0
        private void ForwardData(string interestName, string data, PITEntry pITEntry)
        {
            string fileName = ConfigurationHelper.ProcessDataFilePath + DateTime.Now.Ticks;

            try
            {
                // Check if file already exists. If yes, delete it.
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }

                // Create a new file
                using (FileStream fs = File.Create(fileName))
                {
                    // Add some text to file
                    Byte[] title = new UTF8Encoding(true).GetBytes("Process Data");
                    fs.Write(title, 0, title.Length);
                    byte[] interestNameInfo = new UTF8Encoding(true).GetBytes(interestName);
                    fs.Write(interestNameInfo, 0, interestNameInfo.Length);
                    Byte[] dataInfo = new UTF8Encoding(true).GetBytes(data);
                    fs.Write(dataInfo, 0, dataInfo.Length);
                    byte[] incomingFaceInfo = new UTF8Encoding(true).GetBytes(pITEntry.IncommingFace.ToString());
                    fs.Write(incomingFaceInfo, 0, incomingFaceInfo.Length);
                    Byte[] OutGoingFace = new UTF8Encoding(true).GetBytes(pITEntry.OutGoingFace);
                    fs.Write(OutGoingFace, 0, OutGoingFace.Length);
                }
            }
            catch (Exception Ex)
            {
                Console.WriteLine(Ex.ToString());
            }
        }
Exemple #3
0
 public void AddPITEntry(PITEntry pITEntry)
 {
     try
     {
         pITEntry.EntryCreationTime = DateTime.UtcNow;
         _pITRepository.Add(pITEntry);
     }
     catch (Exception ex)
     {
         LogHelper.WriteExceptionLog(ex);
     }
 }
        private void ForwardNACK(string interestName, string data, PITEntry pITEntry)
        {
            string fileName = ConfigurationHelper.ProcessDataFilePath + DateTime.Now.Ticks;

            try
            {
                // TODO
            }
            catch (Exception Ex)
            {
                Console.WriteLine(Ex.ToString());
            }
        }
Exemple #5
0
 public bool EditPITEntry(PITEntry pITEntry)
 {
     try
     {
         pITEntry.EntryUpdatedTime = DateTime.UtcNow;
         _pITRepository.Edit(pITEntry);
         return(true);
     }
     catch (Exception ex)
     {
         LogHelper.WriteExceptionLog(ex);
         return(false);
     }
 }
Exemple #6
0
        public bool DeletePITEntry(PITEntry pITEntry)
        {
            try
            {
                _pITRepository.Delete(pITEntry);


                return(true);
            }
            catch (Exception ex)
            {
                LogHelper.WriteExceptionLog(ex);
                return(false);
            }
        }
Exemple #7
0
 public string ProcessData(string interestName, string data, string face)
 {
     try
     {
         PITEntry pITEntry = _pitService.GetPITEntryBy(interestName);
         if (pITEntry != null)
         {
             ForwardData(interestName, data, pITEntry);
         }
         else // PIT does not exist - data unsolicited
         {
             // drop
             return(string.Empty);
         }
         return(string.Empty);
     }
     catch (Exception)
     {
         throw;
     }
 }
Exemple #8
0
 public void Edit(PITEntry pITEntries)
 {
     Remove(pITEntries.InterestName);
     Insert(pITEntries.InterestName, pITEntries, TimeToExpireInSecondsDefault);
 }
Exemple #9
0
 public void Delete(PITEntry pITEntries)
 {
     Remove(pITEntries.InterestName);
 }
Exemple #10
0
 public void Add(PITEntry pITEntries)
 {
     Insert(pITEntries.InterestName, pITEntries, TimeToExpireInSecondsDefault);
 }