Ejemplo n.º 1
0
        private void requestFiles()
        {
            // request file

            string fileName = requestFileTxtBox.Text;

            UserXML.File        file        = new UserXML.File(fileName);
            List <UserXML.File> listOfFiles = new List <UserXML.File>();

            listOfFiles.Add(file);
            UserXML userXML = new UserXML(User.Username, User.Password, listOfFiles);

            MediationServer.WebService ws = new MediationServer.WebService();

            string respond = ws.RequestFiles(userXML.getXMLFormatToString());

            if (respond != null)
            {
                UserXML listOfFilesXML = new UserXML(respond);

                listOfFiles = listOfFilesXML.getFilesListWithNumberOfActiveUsers();

                listView.ItemsSource = listOfFiles;
            }
            else
            {
                MessageBox.Show("File not exists");
                listView.ItemsSource = null;
                listView.Items.Clear();
            }
        }
Ejemplo n.º 2
0
        private void Button_Click_2(object sender, RoutedEventArgs e)
        {
            // download
            if (listView.HasItems)
            {
                UserXML.File file = (UserXML.File)listView.SelectedItem;

                if (file != null)
                {
                    SocketListener.FileNameToRequest = file.FileName;

                    MediationServer.WebService ws = new MediationServer.WebService();

                    string targetPeerUsername = ws.GetNameByFilename(file.FileName);

                    peer.Channel.BroadcastPeerToConnect(User.Username, targetPeerUsername);
                }
            }
            else
            {
                MessageBox.Show("Please select an item");
            }
        }