Exemple #1
0
        //test sending/receiving files
        public static void testReceiveBackup()
        {
            Guid          myGuid = Guid.NewGuid();
            CommandServer cs     = new CommandServer(myGuid);
            int           x      = 0;

            while (cs.ClientThreadCount() == 0)
            {
                x++;
                Thread.Sleep(1000);
                Print("waiting for message. " + x);
            }
            ClientThread ct = cs.getClientThread();

            Print("got client thread.");
            while (ct.EventCount() == 0)
            {
                x++;
                Thread.Sleep(1000);
                Print("waiting to receive request." + x);
            }
            Print("received request.");
            PushRequest pr = (PushRequest)ct.DequeueEvent();

            Print("request: " + pr.FileSize + ' ' + Path.GetFileName(pr.Path));
            ct.AcceptFileTransfer(pr, "C:\\Users\\411blue\\desktop\\temp\\scratch 2\\" + Path.GetFileName(pr.Path));
            Print("responded to PushRequest.");
            while (ct.IsWorking())
            {
                x++;
                Thread.Sleep(1000);
                Print("waiting for ClientThread to finish working." + x);
            }
            ct.RequestStop();
            Print("requested clientthread stop");
            cs.Stop();
            Print("stopped CommandServer.");
            Console.WriteLine("press a key to continue");
            Console.ReadKey();
        }