예제 #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();
 }
예제 #2
0
 //tests receiving and responding to QueryRequests
 static void testQueryRequestServer()
 {
     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.");
     QueryRequest qr = (QueryRequest)ct.DequeueEvent();
     Print("request: " + qr.QueryType);
     ct.RespondToQuery(qr);
     Print("responded to query.");
     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();
 }