예제 #1
0
파일: OpCore.cs 프로젝트: nandub/DeOps
        // initializing lookup network (from the settings of a loaded operation)
        public OpCore(DeOpsContext context)
        {
            Context = context;
            Sim     = context.Sim;

            StartTime   = TimeNow;
            GuiProtocol = new G2Protocol();

            Network = new DhtNetwork(this, true);

            // for each core, re-load the lookup cache items
            Context.Cores.LockReading(() =>
            {
                foreach (OpCore core in Context.Cores)
                {
                    core.User.Load(LoadModeType.LookupCache);
                }
            });

            ServiceBandwidth[DhtServiceID] = new BandwidthLog(RecordBandwidthSeconds);

            // get cache from all loaded cores
            AddService(new LookupService(this));

            if (Sim != null)
            {
                Sim.Internet.RegisterAddress(this);
            }

            CoreThread      = new Thread(RunCore);
            CoreThread.Name = "Lookup Thread";

            if (Sim == null || Sim.Internet.TestCoreThread)
            {
                CoreThread.Start();
            }
        }
예제 #2
0
파일: OpCore.cs 프로젝트: nandub/DeOps
        // initializing operation network
        public OpCore(DeOpsContext context, string userPath, string pass)
        {
            Context = context;
            Sim     = context.Sim;

            StartTime   = TimeNow;
            GuiProtocol = new G2Protocol();

            User = new OpUser(userPath, pass, this);
            User.Load(LoadModeType.Settings);

            Network = new DhtNetwork(this, false);

            TunnelID = (ushort)RndGen.Next(1, ushort.MaxValue);

            Test test = new Test(); // should be empty unless running a test

            User.Load(LoadModeType.AllCaches);

            // delete data dirs if frsh start indicated
            if (Sim != null && Sim.Internet.FreshStart)
            {
                for (int service = 1; service < 20; service++)  // 0 is temp folder, cleared on startup
                {
                    string dirpath = User.RootPath + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + service.ToString();
                    if (Directory.Exists(dirpath))
                    {
                        Directory.Delete(dirpath, true);
                    }
                }
            }

            if (Sim != null)
            {
                KeyMax = 32;
            }

            Context.KnownServices[DhtServiceID] = "Dht";
            ServiceBandwidth[DhtServiceID]      = new BandwidthLog(RecordBandwidthSeconds);

            // permanent - order is important here
            AddService(new TransferService(this));
            AddService(new LocationService(this));
            AddService(new LocalSync(this));
            AddService(new BuddyService(this));
            AddService(new UpdateService(this));

            if (!User.Settings.GlobalIM)
            {
                AddService(new TrustService(this));
            }


            // optional
            AddService(new IMService(this));
            AddService(new ChatService(this));
            AddService(new ShareService(this));

            if (Type.GetType("Mono.Runtime") == null)
            {
                AddService(new VoiceService(this));
            }

            if (!User.Settings.GlobalIM)
            {
                AddService(new ProfileService(this));
                AddService(new MailService(this));
                AddService(new BoardService(this));
                AddService(new PlanService(this));
                AddService(new StorageService(this));
            }

            if (Sim != null)
            {
                Sim.Internet.RegisterAddress(this);
            }

            CoreThread      = new Thread(RunCore);
            CoreThread.Name = User.Settings.Operation + " Thread";

            if (Sim == null || Sim.Internet.TestCoreThread)
            {
                CoreThread.Start();
            }

#if DEBUG
            DebugWindowsActive = true;
#endif
        }