Exemple #1
0
        protected override void OnStart(string[] args)
        {
            #region logging
            Logger.Log("Started Service");
            #endregion
            #region heartbeats
            net = new Backend.Networker();
            Logger.Debug2("created NetWorker");
            indexdi = new Backend.IndexDistribution();
            Logger.Debug2("created indexdi");
            indexdi.SetDistribute(true);
            Logger.Debug2("set distribute on indexdi");
            messageThread = new Thread(new ThreadStart(net.processMessages));
            Logger.Debug2("created messagethread");
            rxThread = new Thread(new ThreadStart(net.runReceiver));
            Logger.Debug2("created rxThread");
            txThread = new Thread(new ThreadStart(net.runTransmitter));
            Logger.Debug2("created txthread");
            distributionThread = new Thread(new ThreadStart(indexdi.BeginIndexDistribution));
            Logger.Debug2("created dithread");
            net.startTransmitter();
            Logger.Debug2("Started net transmitter");
            txThread.Start();
            Logger.Debug2("Started txthread");
            net.startReciever();
            Logger.Debug2("Started net receiver");
            messageThread.Start();
            Logger.Debug2("started messagethread");
            rxThread.Start();
            Logger.Debug2("Started rxThread");
            distributionThread.Start();
            Logger.Debug2("started dithread");
            #endregion
            #region networking
            commandServer = new CommandServer(guid);
            Logger.Debug2("started CommandServer");
            #endregion
            #region storage
            storageThread = new StorageThread(Node.GetTemporaryDirectory(), this.guid);
            Logger.Debug2("started StorageThread");
            #endregion

            setupWCF();

            mainThread = new Thread(new ThreadStart(MainLoop));
            //MainLoop();
        }
Exemple #2
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();
 }
Exemple #3
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();
 }
        protected override void OnStart(string[] args)
        {
            #region logging
            Logger.Log("Started Service");
            #endregion
            #region heartbeats
            net = new Backend.Networker();
            Logger.Debug2("created NetWorker");
            indexdi = new Backend.IndexDistribution();
            Logger.Debug2("created indexdi");
            indexdi.SetDistribute(true);
            Logger.Debug2("set distribute on indexdi");
            messageThread = new Thread(new ThreadStart(net.processMessages));
            Logger.Debug2("created messagethread");
            rxThread = new Thread(new ThreadStart(net.runReceiver));
            Logger.Debug2("created rxThread");
            txThread = new Thread(new ThreadStart(net.runTransmitter));
            Logger.Debug2("created txthread");
            distributionThread = new Thread(new ThreadStart(indexdi.BeginIndexDistribution));
            Logger.Debug2("created dithread");
            net.startTransmitter();
            Logger.Debug2("Started net transmitter");
            txThread.Start();
            Logger.Debug2("Started txthread");
            net.startReciever();
            Logger.Debug2("Started net receiver");
            messageThread.Start();
            Logger.Debug2("started messagethread");
            rxThread.Start();
            Logger.Debug2("Started rxThread");
            distributionThread.Start();
            Logger.Debug2("started dithread");
            #endregion
            #region networking
            commandServer = new CommandServer(guid);
            Logger.Debug2("started CommandServer");
            #endregion
            #region storage
            storageThread = new StorageThread(Node.GetTemporaryDirectory(), this.guid);
            Logger.Debug2("started StorageThread");
            #endregion

            setupWCF();

            mainThread = new Thread(new ThreadStart(MainLoop));
            //MainLoop();
        }