Exemplo n.º 1
0
    void Awake()
    {
        instance = this;
        if (!isInit)
        {
            go = new GameObject("DontDestroy");
            go.AddComponent <Network>();
            mbox = Instantiate((GameObject)Resources.Load("Prefab/MessageBox"));
            mbox.transform.parent = go.transform;
            isInit = true;
            DontDestroyOnLoad(go);

            Network.OnError = (connectId, errmsg) =>
            {
                var str = string.Format("Sessonid: {0} ErrorMessage: {1}", connectId, errmsg);
                if (connectId == UserData.GameSeverID)
                {
                    MessageBox.Show(str, (res) => {
                        SceneManager.LoadScene("Login");
                    });
                }
                Debug.Log(str);
            };
        }
    }
        public void it_should_throw_a_concurrency_exception()
        {
            var eventStream = Prepare.Events(new AccountTitleChangedEvent("Title"))
                              .ForSourceUncomitted(EventSourceId, Guid.NewGuid());

            EventStore.Store(eventStream);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 変換を行います。
        /// </summary>
        /// <param name="parameter">変換パラメーター。</param>
        public ConvertResultType Convert(IConvertParameter parameter)
        {
            var cea = new CancelEventArgs();

            cea.Cancel = false;
            Prepare?.Invoke(parameter, cea);
            if (cea.Cancel)
            {
                var r = new ConvertResultType();
                r = ConvertResultType.Cancelled;
                var ccea = new ConvertCompleteEventArgs();
                ccea.Result = ConvertResultType.Cancelled;
                ConvertCompleted?.Invoke(parameter, ccea);
                return(r);
            }

            try
            {
                return(onConvert(parameter));
            }
            catch (Exception e)
            {
                var result = new ConvertCompleteEventArgs();
                result.Result = ConvertResultType.Failed;
                result.Error  = e;
                ConvertCompleted?.Invoke(parameter, result);
                return(result.Result);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Contacts server for Login Check
        /// </summary>
        /// <param name="Username">Username</param>
        /// <param name="Password">Password</param>
        /// <param name="HWID">Hardware ID</param>
        /// <param name="Token">Users Token</param>
        /// <returns></returns>
        public string ResetPassword(string Username, string Password)
        {
            if (!clientSocket.Connected)
            {
                Connect();
            }

            CleanStream();

            if (!Prepare.PrepareString(Password))
            {
                if (!Prepare.PrepareString(Password))
                {
                    Log.Write("Prepare Failed: Password="******"Empty Credentials");
            }

            //Sockets Connection
            //Debug - Log Times
            Stopwatch timer = new Stopwatch();

            timer.Start();

            string Response = API.SendAPIRequest(clientSocket, "Request=ResetPassword&Username="******"&Password="******"&HWID=" + FingerPrint.Value());

            Log.Write(timer.Elapsed.TotalMilliseconds + "ms");

            timer.Reset();

            return(Response);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get Anyones Account Details (Admin)
        /// </summary>
        /// <param name="Token">User Auth-Token</param>
        public string AdminGetAccountDetails(string Username, string Token)
        {
            if (!clientSocket.Connected)
            {
                Connect();
            }

            CleanStream();

            if (!Prepare.PrepareString(Token))
            {
                if (!Prepare.PrepareString(Token))
                {
                    Log.Write("Prepare Failed: Token=" + Token);
                }

                return("Empty Token");
            }

            //Sockets Connection
            //Debug - Log Times
            Stopwatch timer = new Stopwatch();

            timer.Start();

            string Response = API.SendAPIRequest(clientSocket, "Request=AdminGetAccountDetails&Username="******"&Token=" + Token);

            Log.Write(timer.Elapsed.TotalMilliseconds + "ms");

            timer.Reset();

            return(Response);
        }
Exemplo n.º 6
0
        public void Saving_with_concurrent_event_adds_should_not_be_causing_deadlocks()
        {
            // test created in response to an issue with high frequency adds causing deadlocks on the EventSource table.
            // I reworked the sequencing of reads/updates to the EventSource table to reduce the amount
            // of time to any locks will be held. But this wasn't strictly required as the problem resided
            // in the fact that there was no index on the event source table result in full table scans occuring.
            // I therefore also changed the DDL to incude an non clustered index on EventSource.Id which resulted
            // in a nice performance boost during informal testing.

            var targetStore = new MsSqlServerEventStore(connectionString);

            var tasks = new Task[30]; // this number require to reproduce the issue might vary depending on hardware

            for (int idx = 0; idx < tasks.Length; idx++)
            {
                tasks[idx] = Task.Factory.StartNew(() =>
                {
                    var theEventSourceId = Guid.NewGuid();
                    var theCommitId      = Guid.NewGuid();

                    var eventStream = Prepare.Events(new CustomerCreatedEvent(Task.CurrentId.ToString(), 35))
                                      .ForSourceUncomitted(theEventSourceId, theCommitId);

                    // should not be receiving a deadlock
                    targetStore.Store(eventStream);
                });
            }

            Task.WaitAll(tasks);
        }
Exemplo n.º 7
0
        public void Storing_event_source_should_succeed()
        {
            var targetStore      = new MsSqlServerEventStore(connectionString);
            var theEventSourceId = Guid.NewGuid();
            var theCommitId      = Guid.NewGuid();

            var eventStream = Prepare.Events(
                new CustomerCreatedEvent("Foo", 35),
                new CustomerNameChanged("Name" + 2),
                new CustomerNameChanged("Name" + 3),
                new CustomerNameChanged("Name" + 4))
                              .ForSourceUncomitted(theEventSourceId, theCommitId);

            targetStore.Store(eventStream);

            var eventsFromStore = targetStore.ReadFrom(theEventSourceId, long.MinValue, long.MaxValue);

            eventsFromStore.Count().Should().Be(eventStream.Count());

            for (int i = 0; i < eventsFromStore.Count(); i++)
            {
                var uncommittedEvent = eventStream.ElementAt(i);
                var committedEvent   = eventsFromStore.ElementAt(i);

                committedEvent.EventSourceId.Should().Be(uncommittedEvent.EventSourceId);
                committedEvent.EventIdentifier.Should().Be(uncommittedEvent.EventIdentifier);
                committedEvent.EventSequence.Should().Be(uncommittedEvent.EventSequence);
                committedEvent.Payload.GetType().Should().Be(uncommittedEvent.Payload.GetType());
            }
        }
Exemplo n.º 8
0
        public GraphModelType(
            string title,
            string subTitle,

            Encoding xEncoding,
            Encoding yEncoding,

            int numLines,

            Prepare <INPUT, PREPARED> prepare,

            GetLineLabel getLineLabel,

            GetNumXFromInputAndPrepared <INPUT, PREPARED> getNumX,
            GetXFromInputAndPrepared <INPUT, PREPARED> getX,
            GetYFromInputAndPrepared <INPUT, PREPARED> getY
            )
        {
            this.Title    = title;
            this.SubTitle = subTitle;

            this.DataPointFormat = new DataPointFormat(xEncoding, yEncoding);

            this.NumLines = numLines;

            this.prepare = prepare;

            this.getLineLabel = getLineLabel;

            this.getNumX = getNumX;
            this.getX    = getX;
            this.getY    = getY;
        }
Exemplo n.º 9
0
        public static void MaterializeView(Parse parse, Table view, Expr where_, int curId)
        {
            Context ctx = parse.Ctx;
            int db = Prepare.SchemaToIndex(ctx, view.Schema);

            where_ = Expr.Dup(ctx, where_, 0);
            SrcList from = Parse.SrcListAppend(ctx, null, null, null);

            if (from != null)
            {
                Debug.Assert(from.Srcs == 1);
                from.Ids[0].Name = view.Name;
                from.Ids[0].Database = ctx.DBs[db].Name;
                Debug.Assert(from.Ids[0].On == null);
                Debug.Assert(from.Ids[0].Using == null);
            }

            Select select = Select.New(parse, 0, from, where_, 0, 0, 0, 0, 0, 0);
            if (select != null) select.SelFlags |= SF.Materialize;

            SelectDest dest = new SelectDest();
            Select.DestInit(dest, SRT.EphemTab, curId);
            Select.Select(parse, select, dest);
            Select.Delete(ctx, select);
        }
Exemplo n.º 10
0
        public void Overflow_gas_cost()
        {
            Prepare input = Prepare.EvmCode.FromCode("0000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000010001");
            long    gas   = ModExpPrecompile.Instance.DataGasCost(input.Done, Berlin.Instance);

            gas.Should().Be(long.MaxValue);
        }
Exemplo n.º 11
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            ContentManager.LoadContent(); //Loads all the content
            IsMouseVisible = true;
            graphics.PreferredBackBufferWidth  = 1280;
            graphics.PreferredBackBufferHeight = 720;
            graphics.ApplyChanges();
            myState = State.LOAD;

            #region Content

            myMenuButton = Content.Load <Texture2D>("Menu/Button");
            myFont       = Content.Load <SpriteFont>("Menu/Font");

            #endregion

            myLoad       = new Load();
            myMenu       = new Menu();
            myPrepare    = new Prepare();
            myMapManager = new MapManager();
            myUpgrade    = new Upgrade();
            Bullet tempBullet = new Bullet(Content.Load <Texture2D>("Bullets/Bullet01"));

            spriteBatch = new SpriteBatch(GraphicsDevice);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Производит единичную попытку выполнить действие работы,
        /// выполняет подготовительный и непосредственный этапы работы
        /// </summary>
        /// <param name="input">Входные данные для подготовительного этапа</param>
        /// <returns></returns>
        internal virtual TOutput ExecuteInternal(TInput input)
        {
            Prepare?.Invoke(input);
            Log.Warn(Description);

            return(Process.Invoke());
        }
Exemplo n.º 13
0
 public MessageFixture()
 {
     c  = new Commit();
     nv = new NewView();
     p  = new Prepare();
     pp = new PrePrepare();
     vc = new ViewChange();
 }
Exemplo n.º 14
0
 protected override IEnumerable <SourcedEvent> Given()
 {
     return(Prepare.Events
            (
                new NewProjectCreated(TheId, OldName, "myproject")
            )
            .ForSource(TheId));
 }
Exemplo n.º 15
0
 void PrepareCallback(Prepare handle)
 {
     this.prepareCalled++;
     if (this.prepareCalled == NumberOfticks)
     {
         handle.Stop();
     }
 }
Exemplo n.º 16
0
        protected override void AdditionalSetup()
        {
            _data = Prepare.Bytes(PackageSize);

            Task kronos = KronosClient.ClearAsync();
            Task redis  = RedisServer.FlushAllDatabasesAsync();

            Task.WaitAll(kronos, redis);
        }
Exemplo n.º 17
0
 protected override IEnumerable <SourcedEvent> Given()
 {
     return(Prepare.Events
            (
                new NewProjectCreated(TheProjectId, "My Project", "myproject"),
                new MemberAddedToProject(TheMemberId)
            )
            .ForSource(TheProjectId));
 }
Exemplo n.º 18
0
        public void it_should_throw_a_concurrency_exception()
        {
            var eventStream = Prepare.Events(new AccountTitleChangedEvent("Title"))
                              .ForSourceUncomitted(EventSourceId, Guid.NewGuid());

            ConcurrencyException ex = Assert.Throws <ConcurrencyException>(() => EventStore.Store(eventStream));

            Assert.NotNull(ex);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Contacts server for Login Check
        /// </summary>
        /// <param name="Username">Username</param>
        /// <param name="Password">Password</param>
        /// <param name="HWID">Hardware ID</param>
        /// <param name="Token">Users Token</param>
        /// <returns></returns>
        public string Login(string Username, string Password, out string Token)
        {
            string Success;

            if (!clientSocket.Connected)
            {
                Connect();
            }

            CleanStream();

            Token = "";

            if (!Prepare.PrepareString(Username) || !Prepare.PrepareString(Password))
            {
                if (!Prepare.PrepareString(Username))
                {
                    Log.Write("Prepare Failed: Username="******"Prepare Failed: Password="******"Empty Credentials");
            }

            //Sockets Connection
            //Debug - Log Times
            Stopwatch timer = new Stopwatch();

            timer.Start();

            string Response = API.SendAPIRequest(clientSocket, "Request=Login&Username="******"&Password="******"&HWID=" + FingerPrint.Value());

            if (Response.Split('-')[0] == "Login Found")
            {
                Token = Response.Split('-')[1];

                Log.Write("Login Found: " + Username + " -> " + Password + " -> " + Token);

                Success = "Login Found";
            }
            else
            {
                Log.Write("Error: Login not Found -> " + Response);

                Success = Response;
            }

            Log.Write(timer.Elapsed.TotalMilliseconds + "ms");

            timer.Reset();

            return(Success);
        }
Exemplo n.º 20
0
        public void Loading_it_from_history_should_apply_all_events()
        {
            var aggId        = Guid.NewGuid();
            var stream       = Prepare.Events(new HandledEvent(), new HandledEvent(), new HandledEvent()).ForSource(aggId);
            var theAggregate = new MyAggregateRoot(aggId);

            theAggregate.InitializeFromHistory(stream);

            theAggregate.FooEventHandlerInvokeCount.Should().Be(3);
        }
Exemplo n.º 21
0
        void PrepareCallback(Prepare handle)
        {
            if (handle != null &&
                this.prepareCalled == 0)
            {
                this.prepareCalled++;

                this.task = Task.Run(() => this.AsyncSend());
            }
        }
Exemplo n.º 22
0
        void Prepare1Callback(Prepare handle)
        {
            if (this.loopIteration % 2 == 0)
            {
                this.prepare2?.Start(this.Prepare2Callback);
            }

            this.prepare1Called++;
            this.loopIteration++;
        }
Exemplo n.º 23
0
        protected override void AdditionalSetup()
        {
            _data = Prepare.Bytes(PackageSize);

            Task kronos = KronosClient.ClearAsync();

            Task[] redisTasks = RedisServers.Select(x => x.FlushAllDatabasesAsync()).ToArray();
            Task.WaitAll(redisTasks);
            Task.WaitAll(kronos);
        }
Exemplo n.º 24
0
        void PrepareCallback(Prepare handle)
        {
            if (this.prepareCalled == 0)
            {
                this.thread = new Thread(this.ThreadStart);
                this.thread.Start();
            }

            this.prepareCalled++;
        }
Exemplo n.º 25
0
        public void Init_should_set_From_and_To_version_information()
        {
            var sourceId        = Guid.NewGuid();
            var eventObjects    = new[] { new Object(), new Object(), new Object() };
            var committedEvents = Prepare.Events(eventObjects).ForSource(sourceId, 5).ToList();

            var sut = new CommittedEventStream(sourceId, committedEvents);

            sut.FromVersion.Should().Be(committedEvents.First().EventSequence);
            sut.ToVersion.Should().Be(committedEvents.Last().EventSequence);
        }
Exemplo n.º 26
0
        public Config(Invoker invoker)
        {
            Invoker                  = invoker;
            Factory                  = MenuFactory.Create("Invoker Crappahilation");
            ComboKey                 = Factory.Item("Combo Key", new KeyBind('G'));
            MinDisInOrbwalk          = Factory.Item("Min distance in orbwalk", new Slider(1, 1, 600));
            DrawMinDistanceInOrbwalk = Factory.Item("Draw this range", true);
            InvokeTime               = Factory.Item("Time between spheres in combo", new Slider(1, 1, 200));
            AfterInvokeDelay         = Factory.Item("Delay after Invoke", new Slider(1, 1, 500));
            SsExtraDelay             = Factory.Item("Sun Strike Extra Delay", new Slider(15, 0, 25));
            SsExtraDelay.Item.SetTooltip("dec this value if you cant hit target by ss");
            //Ensage.SDK.Orbwalker.Modes.Farm
            SmartInvoke = Factory.Item("Smart invoke", false);
            SmartInvoke.Item.SetTooltip("will check for spheres before invoke");

            ExpInvoke = Factory.Item("Experemental invoke", true);
            ExpInvoke.Item.SetTooltip("Enable this if your hero cant use invoke properly and disable [SmartInvoke]");

            ExtraDelayAfterSpells = Factory.Item("Extra delay after each ability in combo", true);
            ExtraDelayAfterSpells.Item.SetTooltip("Enable this if your hero sometimes not use abilities");

            AutoIceWall = Factory.Item("Dummy IceWall", true);
            AutoIceWall.Item.SetTooltip("Hero will run to the enemy");

            SmartMove = Factory.Item("Move to target if ability out of range", true);
            Cataclysm = Factory.Item("Use SS'cataclysm (talant) in combo", false);

            AbilityPanel     = new AbilityPanel(this);
            ComboPanel       = new ComboPanel(this);
            SmartSphere      = new SmartSphere(this);
            AutoSunStrike    = new AutoSunStrike(this);
            AutoGhostWalk    = new AutoGhostWalk(this);
            Prepare          = new Prepare(this);
            ExortForFarmMode = new ExortForFarmMode(this);
            CustomCombos     = new CustomCombos(this);

            var panel = Factory.Menu("Abilities");
            var dict  = invoker.AbilityInfos.Select(x => x.Ability.Name).ToDictionary(result => result, result => true);

            AbilitiesInCombo = panel.Item("Abilities in combo", new AbilityToggler(dict));
            var dict2 = new Dictionary <string, bool>
            {
                { AbilityId.item_blink.ToString(), true },
                { AbilityId.item_sheepstick.ToString(), true },
                { AbilityId.item_shivas_guard.ToString(), true },
                { AbilityId.item_orchid.ToString(), true },
                { AbilityId.item_bloodthorn.ToString(), true },
            };

            ItemsInCombo = panel.Item("Items in combo", new AbilityToggler(dict2));

            //Factory.Target.TextureName = "npc_dota_hero_invoker";
            //Factory.Target.ShowTextWithTexture = true;
        }
Exemplo n.º 27
0
        public void PrepareCallback()
        {
            Prepare prepare = this.loop
                              .CreatePrepare()
                              .Start(this.OnPrepare);

            this.loop.RunDefault();
            Assert.Equal(1, this.callbackCount);

            this.CloseHandle(prepare);
        }
Exemplo n.º 28
0
        public void Prepare()
        {
            Prepare prepare = this.loop.CreatePrepare().Start(this.OnCallback);

            prepare.RemoveReference();

            this.loop.RunDefault();
            Assert.Equal(0, this.callbackCount);

            this.CloseHandle(prepare);
        }
Exemplo n.º 29
0
        public void Redis()
        {
            Parallel.For(0, Clients, _ =>
            {
                string key = Prepare.Key();

                RedisClient.StringSetAsync(key, _data).GetAwaiter().GetResult();
                RedisClient.StringGetAsync(key).GetAwaiter().GetResult();
                RedisClient.KeyDeleteAsync(key).GetAwaiter().GetResult();
            });
        }
Exemplo n.º 30
0
        public void Dispose()
        {
            this.prepare?.Dispose();
            this.prepare = null;

            this.pipe?.Dispose();
            this.pipe = null;

            this.loop?.Dispose();
            this.loop = null;
        }
Exemplo n.º 31
0
		public void Should_accept_the_value()
		{
			var acceptor = new Acceptor<string>(_serviceId)
			{
				Bus = _bus,
			};

			InboundMessageHeaders.SetCurrent(x =>
				{
					x.ReceivedOn(_bus);
					x.SetObjectBuilder(_builder);
					x.SetResponseAddress("loopback://localhost/queue");
				});

			Prepare<string> prepare = new Prepare<string>
				{
					BallotId = 1,
					CorrelationId = _serviceId,
					LeaderId = _leaderId,
				};

			acceptor.RaiseEvent(Acceptor<string>.Prepare, prepare);

			acceptor.CurrentState.ShouldEqual(Acceptor<string>.Prepared);

			var accept = new Accept<string>
			{
				BallotId = 1,
				CorrelationId = _serviceId,
				LeaderId = _leaderId,
				Value = "Chris",
			};

			acceptor.RaiseEvent(Acceptor<string>.Accept, accept);

			acceptor.CurrentState.ShouldEqual(Acceptor<string>.SteadyState);
			acceptor.Value.ShouldEqual(accept.Value);
			acceptor.BallotId.ShouldEqual(accept.BallotId);

			_endpoint.VerifyAllExpectations();
		}
Exemplo n.º 32
0
    void Start()
    {
        _createfood.enabled = false;
        _createitems.enabled = false;
        _createweather.enabled = false;

        //初始化狀態機
        Prepare _p = new Prepare();
        Gaming _g = new Gaming();
        EndingPrepare _ep = new EndingPrepare();
        GameEnd _e = new GameEnd();

        _p.AddTransition(_g, "GoGaming");
        _g.AddTransition(_ep, "GoPrepareEnd");
        _ep.AddTransition(_e, "GoEnd");

        AddState(_p, "PrepareGame");
        AddState(_g, "Gaming");
        AddState(_ep, "PrepareEnd");
        AddState(_e, "TheEnd");

        InitFSM();
    }