private void StartedMsgHandler(StartMessage msg) { Started = msg.Started; if (Started) { StartTimer(); } else { StopTimer(); } if (Started) { State = "Drink a cup of coffee, the processing of data is going..."; } if (!Started && App.Current.MainWindow.WindowState == System.Windows.WindowState.Minimized) { App.Current.MainWindow.WindowState = System.Windows.WindowState.Normal; } if (!Started && msg.SuccessfullyCompleted) { State = "Successfully completed"; } if (!Started && !msg.SuccessfullyCompleted) { State = "Completed with errors (see details in the log file)"; } }
public async Task Handle(StartMessage message, IMessageHandlerContext context) { await RequestTimeout(context, TimeSpan.FromDays(7), new TimeoutMessage1()); await RequestTimeout(context, TimeSpan.FromDays(14), new TimeoutMessage2()); await RequestTimeout(context, new DateTime(2010, 1, 7, 0, 0, 0, DateTimeKind.Utc), new DateTimeTimeOutMessage1()); await RequestTimeout(context, new DateTime(2010, 1, 14, 0, 0, 0, DateTimeKind.Utc), new DateTimeTimeOutMessage2()); }
// Server messages public static void SendStart(int connectionId, bool isHost) { StartMessage msg = new StartMessage(); msg.id = connectionId; msg.host = isHost; NetworkServer.SendToClient(connectionId, PongMsgType.Start, msg); }
public void Handle(StartMessage message) { Data.SomeID = message.SomeID; ReplyToOriginator(new AlmostDoneMessage { SomeID = Data.SomeID }); }
public async Task Execute(StartMessage message) { await Task.Run(() => { Data.CorrelationId = message.CorrelationId; Console.WriteLine("Received start."); _bus.Send("AsyncProcessManager.Consumer", new MessageRequest(message.CorrelationId)); }); }
private async Task OnStart(StartMessage message) { _ = message?.MessageId switch { var id when id.Equals(Server.UniqueIdentifier) => await StartServer(message.Start), var id when id.Equals(Client.UniqueIdentifier) => await StartClient(message.Start), null => throw new ArgumentException(message: $"Invalid Message: A message must have a Unique Id. This message has no Id."), _ => throw new ArgumentException(message: $"Unhandled Message: A message with an unrecognized Id has been received. The Id of this message is {message?.MessageId}.") }; }
public void AddTwoMessagesWithGapInSequence_ThrowsGameOutOfSyncException_Test() { // Arrange var startMsg = StartMessage.Create(1); var endMsg = EndMessage.Create(3); // Act & Assert _quest.AddMessage(_gameId, startMsg); Assert.Throws <GameOutOfSyncException>(() => _quest.AddMessage(_gameId, endMsg)); }
public void StartGameTwice_ThrowsException_Test() { // Arrange var start = StartMessage.Create(1); var secondStart = StartMessage.Create(2); // Act & Assert _quest.AddMessage(_gameId, start); Assert.Throws <InvalidActionException>(() => _quest.AddMessage(_gameId, secondStart)); }
public void A_ClaimSubmitted_message_is_received() { Message = new StartMessage { CorrelationId = SagaId, MessageId = _claimId.ToString(), Amount = _amount }; LocalBus.Publish(Message); }
public void StartGame_ResultsInBeginTimestampBeginSet_Test() { // Arrange var start = StartMessage.Create(1); // Act var game = _quest.AddMessage(_gameId, start); // Assert Assert.NotNull(game.Score.Begin); Assert.Equal(start.Timestamp, game.Score.Begin); }
public void StartGame_ThenUndoIt_ResultsInTimestampBeingSetToNull_Test() { // Arrange var start = StartMessage.Create(1); // Act _quest.AddMessage(_gameId, start); var game = _quest.Undo(_gameId); // Assert Assert.Null(game.Score.Begin); }
private void OnStartMessage(int sender, IPCMessage msg) { StartMessage startMsg = (StartMessage)msg; Chat.WriteLine("OnStartMessage"); ActiveGlobalSettings = new GlobalSettings { Sector = startMsg.Sector }; Leader = new Identity(IdentityType.SimpleChar, sender); Start(); }
private void OnStartMessage(int sender, IPCMessage msg) { StartMessage startMsg = (StartMessage)msg; Chat.WriteLine("OnStartMessage"); ActiveGlobalSettings = new GlobalSettings { MissionDifficulty = startMsg.MissionDifficulty, MissionFaction = startMsg.MissionFaction }; Leader = new Identity(IdentityType.SimpleChar, sender); Start(); }
public void AddMessageToQuest_ResultsInMessageBeingPutIntoProtocol_Test() { // Arrange var startMsg = StartMessage.Create(1); // Act _quest.AddMessage(_gameId, startMsg); // Assert var game = _gameStore.Get(_gameId); Assert.Single(game.Protocol); }
public void EndingGameTwice_ThrowsException_Test() { // Arrange var quest = QuestFactory.CreateStored(out var gameStore, out var gameId); var startMsg = StartMessage.Create(1); var endMsg = EndMessage.Create(2); var secondEndMsg = EndMessage.Create(3); // Act & Assert quest.AddMessage(gameId, startMsg); quest.AddMessage(gameId, endMsg); Assert.Throws <InvalidActionException>(() => quest.AddMessage(gameId, secondEndMsg)); }
public void StartGame() { GameRunning = true; Manager.UI.Message.Hide(); if (authoritative) { StartMessage start = new StartMessage(); Manager.Network.Engine.Send(start, LiteNetLib.SendOptions.ReliableOrdered); LaunchBall(1); } }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req, [Queue("starts")] ICollector <string> definition, ILogger log) { // Expecting start parameters as JSON object in request body. // Everything to be passed through to the container should start with "pipeline.". const string processNameKey = "pipeline.processName"; const string containerImageKey = "containerImage"; const string defaultContainerImage = "msimecek/speech-pipeline:latest"; var reqStr = await req.ReadAsStringAsync(); var reqObj = JObject.Parse(reqStr); if (!reqObj.ContainsKey(processNameKey) || string.IsNullOrWhiteSpace(reqObj[processNameKey].Value <string>())) { return(new BadRequestObjectResult($"Process name is required. Provide value in the {processNameKey} parameter.")); } string containerImage = (reqObj.ContainsKey(containerImageKey)) ? reqObj[containerImageKey].Value <string>() : defaultContainerImage; var env = new Dictionary <string, string>(); foreach (var e in reqObj) { var key = e.Key.ToString(); if (key.StartsWith("pipeline.")) { if (!string.IsNullOrWhiteSpace(e.Value.ToString())) { env.Add(key.Replace("pipeline.", ""), e.Value.ToString()); } } } var message = new StartMessage() { Env = env, ContainerImage = containerImage, ContainerName = reqObj[processNameKey].Value <string>(), Location = Environment.GetEnvironmentVariable("Location"), ResourceGroup = Environment.GetEnvironmentVariable("ResourceGroupName"), }; definition.Add(JsonConvert.SerializeObject(message)); return(new AcceptedResult()); }
public void AddStartAndEndMessagesWithCorrectSequence_ResultsInEndedGame_Test() { // Arrange var startMsg = StartMessage.Create(1); var endMsg = EndMessage.Create(2); // Act _quest.AddMessage(_gameId, startMsg); var game = _quest.AddMessage(_gameId, endMsg); // Assert Assert.NotNull(game.Score.Begin); Assert.NotNull(game.Score.End); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); var batTexture = Content.Load <Texture2D>("Bat"); var ballTexture = Content.Load <Texture2D>("Ball"); _score = new Score(Content.Load <SpriteFont>("TitleFont")); _winMessage = new WinMessage(Content.Load <SpriteFont>("WinMessageFont")); _SFBounce = Content.Load <SoundEffect>("SFBounce"); _SFScore = Content.Load <SoundEffect>("SFScore"); _songGameTitle = Content.Load <Song>("SongGameTitle"); _songGameStart = Content.Load <Song>("SongGameStart"); _songGameOver = Content.Load <Song>("SongGameOver"); _title = new Title(Content.Load <Texture2D>("Title")); _startMessage = new StartMessage(Content.Load <Texture2D>("StartMessage")); _sprites = new List <Sprite>() { new Sprite(Content.Load <Texture2D>("Background")), new Bat(batTexture) { position = new Vector2(20, (screenHeight / 2) - (batTexture.Height / 2)), input = new Models.Input() { up = Keys.W, down = Keys.S } }, new Bat(batTexture) { position = new Vector2(screenWidth - 20 - batTexture.Width, (screenHeight / 2) - (batTexture.Height / 2)), input = new Models.Input() { up = Keys.Up, down = Keys.Down } }, new Ball(ballTexture) { position = new Vector2((screenWidth / 2) - (ballTexture.Width / 2), (screenHeight / 2) - (ballTexture.Height / 2)), score = _score, winMessage = _winMessage, SFBounce = _SFBounce, SFScore = _SFScore } }; PlayMusic(); // TODO: use this.Content to load your game content here }
public void AddMessageToQuest_ThenUndoIt_ResultsInEmptyProtocol_Test() { // Arrange var startMsg = StartMessage.Create(1); // Act _quest.AddMessage(_gameId, startMsg); _quest.Undo(_gameId); // Assert var game = _gameStore.Get(_gameId); Assert.Empty(game.Protocol); }
public void EndingAStartedGame_EndsItByAddingTimestamp_Test() { // Arrange var quest = QuestFactory.CreateStored(out var gameStore, out var gameId); var startMsg = StartMessage.Create(1); var endMsg = EndMessage.Create(2); // Act quest.AddMessage(gameId, startMsg); var game = quest.AddMessage(gameId, endMsg); // Assert Assert.NotNull(game.Score.End); Assert.Equal(endMsg.Timestamp, game.Score.End); }
public void EndingGame_ThenUndoIt_RemovesTheEndTimestamp_Test() { // Arrange var quest = QuestFactory.CreateStored(out var gameStore, out var gameId); var startMsg = StartMessage.Create(1); var endMsg = EndMessage.Create(2); // Act quest.AddMessage(gameId, startMsg); quest.AddMessage(gameId, endMsg); var game = quest.Undo(gameId); // Assert Assert.Null(game.Score.End); }
public void Should_have_called_combined_event() { Bus.InboundPipeline.Trace(); var responseReceived = new FutureMessage <CompleteMessage>(); Bus.SubscribeHandler <CompleteMessage>(responseReceived.Set); var message = new StartMessage(); Bus.Publish(message); Bus.Publish(new FirstMessage(message.CorrelationId)); Bus.Publish(new SecondMessage(message.CorrelationId)); Assert.IsTrue(responseReceived.IsAvailable(TestHelper.MessageTimeout)); }
public void start(string strmessage) { string[] split = strmessage.Split('#'); StartMessage start = new StartMessage() { Timestamp = DateTime.Parse(split[3]), Peers = split[4].Split(',') }; WEB.ID = split[0]; WEB.ROOM = split[1]; WEB.HOST = split[2]; onStart(start); Debug.Log(string.Format("Starting game {0} at {1}", WEB.ROOM, start.Timestamp)); }
private async void Start() { MessengerInstance.Send(StartMessage.AnalyzeStarted()); try { var settings = Common.GetAnalyzerSettings <QueriesAnalyzeViewModel, QueriesAnalyzerSettings>(this); var analyzer = new QueriesAnalyzer(settings); await analyzer.Run(); MessengerInstance.Send(StartMessage.SuccessfullyCompeled()); } catch { MessengerInstance.Send(StartMessage.UnsuccessfullyCompeled()); } }
private void HandleStart(StartMessage message) { if (!StartInitialized) { ViewController.Instance.UpdateNames(PlayerOrderMap, PlayerName); ViewController.Instance.ShowCardsInHand(message.Cards.ToList()); StartInitialized = true; } else { ViewController.Instance.DoOnClear(() => { ViewController.Instance.UnHighlightNames(); ViewController.Instance.ClearInfo(); ViewController.Instance.ShowCardsInHand(message.Cards.ToList()); }); } }
/// <summary> /// Run both EasyNetQ.Tests.SimpleSaga and EasyNetQ.Tests.SimpleService first /// You should see the message hit the SimpleSaga, bounce to the SimpleService /// and then bounce back to the SimpleSaga again before ending here. /// </summary> public void RunSaga() { var autoResetEvent = new AutoResetEvent(false); var bus = RabbitHutch.CreateBus("host=localhost"); bus.Subscribe<EndMessage>("runSaga_spike", endMessage => { Console.WriteLine("Got EndMessage: {0}", endMessage.Text); autoResetEvent.Set(); }); var startMessage = new StartMessage { Text = "Hello Saga! " }; bus.Publish(startMessage); // give the message time to run through the process autoResetEvent.WaitOne(1000); }
/// <summary> /// Run both EasyNetQ.Tests.SimpleSaga and EasyNetQ.Tests.SimpleService first /// You should see the message hit the SimpleSaga, bounce to the SimpleService /// and then bounce back to the SimpleSaga again before ending here. /// </summary> public void RunSaga() { var autoResetEvent = new AutoResetEvent(false); var bus = RabbitHutch.CreateBus("host=localhost"); bus.Subscribe <EndMessage>("runSaga_spike", endMessage => { Console.WriteLine("Got EndMessage: {0}", endMessage.Text); autoResetEvent.Set(); }); var startMessage = new StartMessage { Text = "Hello Saga! " }; bus.Publish(startMessage); // give the message time to run through the process autoResetEvent.WaitOne(1000); }