Beispiel #1
0
        public void shareObject(ObjectFile file)
        {
            ServerToServerServices friend;
            RemoteAsyncShareObjectDelegate del;
            ServerApp._user.addObject(file);
            List<String> uri = new List<string>();
            List<String> contacting = new List<string>();

            contacting.Add(ServerApp._primaryURI);
            uri.Add(ServerApp._primaryURI);
            QueryByFile query = new QueryByFile(file.FileName, uri, contacting, ServerApp._user.Username,DateTime.Now);

            byte[] data = Encoding.Default.GetBytes(query.ToString());
            byte[] signature = ServerApp._rsaProvider.SignData(data, "SHA1");
            SignedQueryByFile signedQuery = new SignedQueryByFile(query, signature);

            MessageBox.Show(ServerApp._user.Username + " :  wants to share " + file.FileName);

            foreach (Friend f in ServerApp._user.Friends)
            {
                if (f.Uris.ElementAt(0) != null && f.SucessorSwarm)
                {
                    friend = ((ServerToServerServices)Activator.GetObject(typeof(ServerToServerServices),
                        f.Uris.ElementAt(0) + "/" + ServicesNames.ServerToServerServicesName));

                    MessageBox.Show(ServerApp._user.Username + " sends to " + f.Name);

                    del = new RemoteAsyncShareObjectDelegate(friend.shareObject);
                    del.BeginInvoke(signedQuery, null, null);
                }
            }
        }
Beispiel #2
0
 public void addObject(ObjectFile file)
 {
     _objectList.Add(file);
 }
Beispiel #3
0
 private void settingsAddObjButton_Click(object sender, EventArgs e)
 {
     ObjectFile file = new ObjectFile(this.settingsAddObjTextBox.Text, "content", 7);
     RemoteAsyncObjectDelegate RemoteDel = new RemoteAsyncObjectDelegate(_server.shareObject);
     IAsyncResult RemAr = RemoteDel.BeginInvoke(file, null, null);
     ClientApp._user.addObject(file);
     this.settingsObjectsRichTextBox2.Clear();
     foreach (ObjectFile f in ClientApp._user.ObjectList)
         this.settingsObjectsRichTextBox2.Text += f.FileName + " : " + f.Content + " ( size = " + f.Size + ")" + "\r\n";
 }