Exemplo n.º 1
0
        public void ReportShares(Share[] shares)
        {
            try
            {
                string address = (OperationContext.Current.
                        IncomingMessageProperties
                            [RemoteEndpointMessageProperty.Name]
                                as RemoteEndpointMessageProperty).Address;

                foreach (var item in shares)
                {
                    if (!_shares.ContainsKey(item))
                    {
                        _shares.Add(item, new HashSet<string>());
                        _log.InfoFormat("File submitted: {0}", item.Name);
                    }
                    _shares[item].Add(address);
                }
            }
            catch (Exception e)
            {
                _log.ErrorFormat("An error occured: {0}", e.Message);
                throw e;
            }
        }
Exemplo n.º 2
0
 public Share[] ListShares()
 {
     try
     {
         Share[] result = new Share[_shares.Keys.Count];
         _shares.Keys.CopyTo(result, 0);
         return result;
     }
     catch (Exception e)
     {
         _log.ErrorFormat("An error occured: {0}", e.Message);
         throw e;
     }
 }
Exemplo n.º 3
0
        public string[] RequestDownload(string hash)
        {
            try
            {
                Share index = new Share { Hash = hash };
                string[] result = new string[_shares[index].Count];
                _shares[index].CopyTo(result);

                _log.InfoFormat("Download requested: {0}, advising: {1}", hash, result[0]);

                return result;
            }
            catch (Exception e)
            {
                _log.ErrorFormat("An error occured: {0}", e.Message);
                throw e;
            }
        }
Exemplo n.º 4
0
 internal void AddRemoteShare(Share share)
 {
     remoteShares.Add(share);
 }