コード例 #1
0
        //-------------------------------------------------------------
        public override void UpdateTorrent(DTO_Torrent torrent)
        //-------------------------------------------------------------
        {
            //Enable GET button if client don't has the game
            if (button_Play.Enabled == false)
            {
                button_Get.Visible = true;
                button_Get.Enabled = true;
            }

            dto_suggestion.torrent = torrent.torrent;
        }
コード例 #2
0
        //-------------------------------------------------------------
        public void GotTorrent(DTO_Torrent torrent)
        //-------------------------------------------------------------
        {
            SuggestedGame suggestedGameControl = suggestedGames.Where(L => L.GetKey().Equals(torrent.key)).FirstOrDefault();

            if (suggestedGameControl == null)
            {
                Log.Get().Write("KobberLan DTO_Torrent unknown title: " + torrent.key, Log.LogType.Error);
            }
            else
            {
                suggestedGameControl.UpdateTorrent(torrent);
            }
        }
コード例 #3
0
        //-------------------------------------------------------------
        public override void UpdateTorrent(DTO_Torrent torrent)
        //-------------------------------------------------------------
        {
            //-------------------------------------------------------------
            //Change layout
            //-------------------------------------------------------------
            label_Downloading.Visible     = true;
            pictureBox_Downloaded.Visible = true;

            //-------------------------------------------------------------
            //Update torrent info (To send to new clients)
            //-------------------------------------------------------------
            dto_suggestion.torrent = torrent.torrent;
        }
コード例 #4
0
        //-------------------------------------------------------------
        public void SendTorrent(DTO_Torrent torrent)
        //-------------------------------------------------------------
        {
            Log.Get().Write("KobberLan DTO_Torrent sending to network");
            //torrentTrackingServer = true; //Enable test port

            //Send packet to LAN
            communication.ClientSend(torrent);

            //Called from TorrentThread
            Invoke(new Action(() =>
            {
                //-------------------------------------------------------------
                //Update own SuggestedGame with torrent info
                //-------------------------------------------------------------
                GotTorrent(torrent);
            }));
        }
コード例 #5
0
        //-------------------------------------------------------------
        private void button_ShareGet_Click(object sender, EventArgs e)
        //-------------------------------------------------------------
        {
            if (button_ShareGet.Text.Equals("Share"))
            {
                Log.Get().Write("Start sharing: " + dto_suggestion.key);
                button_ShareGet.Enabled = false;
                //button_Clear.Enabled = false;
                button_ShareGet.Text = "Stop";

                //-------------------------------------------------------------
                //Run in own thread (To avoid locking gui)
                //-------------------------------------------------------------
                new Thread(() =>
                {
                    torrent = new DTO_Torrent()
                    {
                        key = dto_suggestion.key
                    };

                    //-------------------------------------------------------------
                    //Start creating torrent (hashing)
                    //-------------------------------------------------------------
                    torrent.torrent = Torrent.Get().CreateTorrent(path, dto_suggestion.key).Result;

                    //-------------------------------------------------------------
                    //Check torrent name with key (Stop if mismatch)
                    //-------------------------------------------------------------
                    string torrentKey = Torrent.Get().GetTorrentName(torrent.torrent);
                    if (!torrentKey.Equals(torrent.key))
                    {
                        Log.Get().Write("Torrent name not maching key, trying to delete file. torrentKey:'" + torrentKey + "' suggestkey:'" + torrent.key + "'", Log.LogType.Warning);

                        //-------------------------------------------------------------
                        //Delete torrent file
                        //-------------------------------------------------------------
                        Torrent.Get().DeleteTorrentFile(path);

                        //-------------------------------------------------------------
                        //ReCreate torrent file
                        //-------------------------------------------------------------
                        torrent.torrent = Torrent.Get().CreateTorrent(path, dto_suggestion.key).Result;

                        if (!Torrent.Get().GetTorrentName(torrent.torrent).Equals(torrent.key))
                        {
                            Log.Get().Write("Torrentfile name not maching key, aborting", Log.LogType.Error);
                            return;
                        }
                    }

                    //-------------------------------------------------------------
                    //Insert announce ip
                    //-------------------------------------------------------------
                    torrent.torrent = Torrent.Get().InsertAnnounce(torrent.torrent);

                    //-------------------------------------------------------------
                    //Start tracker
                    //-------------------------------------------------------------
                    Torrent.Get().StartTracker(torrent.torrent);
                }).Start();
            }
            else if (button_ShareGet.Text.Equals("Stop"))
            {
                Log.Get().Write("Stop sharing: " + dto_suggestion.key);

                button_ShareGet.Enabled = false;
                Torrent.Get().StopSharing(dto_suggestion.key);

                button_ShareGet.Enabled = true;
                button_ShareGet.Text    = "Share"; //Possible to start sharing again
            }
        }
コード例 #6
0
 //-------------------------------------------------------------
 public override void UpdateTorrent(DTO_Torrent torrent)
 {
 }
コード例 #7
0
 //-------------------------------------------------------------
 //-------------------------------------------------------------
 public abstract void UpdateTorrent(DTO_Torrent torrent);