public List<ClassLibrary.Entites.SearchFile> SearchFileByName(string fileName) { SuperPeerServiceClient superPeerServiceClient = new SuperPeerServiceClient(); List<ClassLibrary.Entites.SearchFile> filesList = superPeerServiceClient.SearchAvailableFiles(fileName); return filesList; }
public void Leave(Peer peer) { registration.Stop(); SuperPeerServiceClient ssc = new SuperPeerServiceClient(); ssc.RemovePeer(peer); }
public List <ClassLibrary.Entites.SearchFile> SearchFileByName(string fileName) { SuperPeerServiceClient superPeerServiceClient = new SuperPeerServiceClient(); List <ClassLibrary.Entites.SearchFile> filesList = superPeerServiceClient.SearchAvailableFiles(fileName); return(filesList); }
public void AddFile(ClassLibrary.Entites.File file) { SuperPeerServiceClient ssc = new SuperPeerServiceClient(); List<ClassLibrary.Entites.File> tempList = new List<ClassLibrary.Entites.File>(); tempList.Add(file); ssc.AddFiles(tempList); }
public void AddFile(ClassLibrary.Entites.File file) { SuperPeerServiceClient ssc = new SuperPeerServiceClient(); List <ClassLibrary.Entites.File> tempList = new List <ClassLibrary.Entites.File>(); tempList.Add(file); ssc.AddFiles(tempList); }
public void DoHost(Peer peer) { PeerServiceHost.peer = peer; string address = string.Empty; address = string.Format("net.tcp://{0}:{1}/PeerToPeerClient.Services/PeerService", peer.PeerHostName, Config.LocalPort); Uri uri = new Uri(address); NetTcpBinding tcpBinding = new NetTcpBinding(SecurityMode.None); ServiceHost serviceHost = new ServiceHost(typeof(PeerService), uri); serviceHost.AddServiceEndpoint(typeof(IPeerService), tcpBinding, ""); serviceHost.Open(); // add this peer to the server SuperPeerServiceClient ssc = new SuperPeerServiceClient(); ssc.AddPeer(peer); // add the files that this peer wants to share to the server DirectoryInfo dirInfo = new DirectoryInfo(Config.SharedFolder); if (dirInfo.Exists) { FileInfo[] filesInfo = dirInfo.GetFiles(); List<ClassLibrary.Entites.File> files = new List<ClassLibrary.Entites.File>(); foreach (var fileInfo in filesInfo) { ClassLibrary.Entites.File file = new ClassLibrary.Entites.File(); file.FileName = fileInfo.Name; file.FileType = fileInfo.Extension; file.FileSize = fileInfo.Length; SHA512 sha512 = SHA512.Create(); using (var stream = fileInfo.Open(FileMode.Open, FileAccess.Read)) { file.FileHash = BitConverter.ToString(sha512.ComputeHash(stream), 0); } file.PeerName = peer.PeerName; file.PeerID = peer.PeerID; files.Add(file); } if (files.Count != 0) ssc.AddFiles(files); } else dirInfo.Create(); }
public void DeleteFile(ClassLibrary.Entites.File file) { SuperPeerServiceClient ssc = new SuperPeerServiceClient(); ssc.DeleteFile(file); }