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; } }
private void ForwardInterest(FIBEntry fIBEntry, string interestName) { string fileName = ConfigurationHelper.ProcessInterestFilePath + 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 Interest"); fs.Write(title, 0, title.Length); byte[] interestNameInfo = new UTF8Encoding(true).GetBytes(interestName); fs.Write(interestNameInfo, 0, interestNameInfo.Length); Byte[] fibInfo = new UTF8Encoding(true).GetBytes(fIBEntry.FaceInformation); fs.Write(fibInfo, 0, fibInfo.Length); } } catch (Exception Ex) { Console.WriteLine(Ex.ToString()); } }
public void AddFIBEntry(FIBEntry pITEntry) { try { _fIBRepository.Add(pITEntry); } catch (Exception ex) { LogHelper.WriteExceptionLog(ex); } }
public bool EditFIBEntry(FIBEntry pITEntry) { try { _fIBRepository.Edit(pITEntry); return(true); } catch (Exception ex) { LogHelper.WriteExceptionLog(ex); return(false); } }
private void ProcessReceivedClientMessage(NetworkPackage networkPackage) { TimeStamp.WriteLine("Client Message on port " + networkPackage.currentPort); FIBEntry searchedEntry = forwardingTable.Find(x => x.inputPort == networkPackage.currentPort); if (searchedEntry != null) { networkPackage.currentPort = searchedEntry.outputPort; Console.WriteLine("{0} Lambda: {1} -> passing to port {2}", TimeStamp.TAB, searchedEntry.lambda, networkPackage.currentPort); Send(networkPackage); } else { Console.WriteLine("No forwarding entry"); } }
void IFIBRepository.Edit(FIBEntry fIBEntry) { throw new NotImplementedException(); }