private void OnHostReceivedHandshake(IPAddress address) { CreateSenderAndSendHandshake(address); _connected = true; Debug.LogFormat("Connected"); _mainThreadActionsQueue.Enqueue(() => OnStartGame.Dispatch(true)); }
public void Should_keep_handling_order() { using (var queue = new ActionsQueue(log)) { var tmp = 0; Action act1 = () => { tmp += 1; }; Action act2 = () => { tmp *= 2; }; queue.Enqueue(act1); queue.Enqueue(act2); Action check = () => tmp.Should().Be(2); check.ShouldPassIn(defaultTimeout); } }
///<summary> /// Loads the Xml and Execute the test cases /// ///</summary> public void Play() { ActionsQueue queue = new ActionsQueue(); XmlElement element = (XmlElement)_xmlDoc.SelectSingleNode("KeyboardTestCase"); // Retriving the test Xmal Content for set up the environment, right now all the variations share the // same enviroment. XmlElement xamlElement = (XmlElement)element.SelectSingleNode("Xaml"); XmlTextWriter writer = new XmlTextWriter("KeyboardTestEnvironment.xml", System.Text.Encoding.Unicode); xamlElement.WriteContentTo(writer); writer.Close(); // Getting all the Variations XmlNodeList xmlList = element.SelectNodes("RecordActions"); for (int j = 0; j < xmlList.Count; j++) { XmlElement actionTest = (XmlElement)xmlList[j]; ModelTestCase modelTestCase = convertXmlElementToModelTestCase(_model, actionTest); queue.Enqueue(modelTestCase); } // This is actually executing the test cases GeneralTestCaseLoader tcLoader = new GeneralTestCaseLoader(queue); tcLoader.AddModel(_model); tcLoader.Run(); }
private void OnNodeEvent(NodeChangedEventType type, string path) { if (isDisposed) { return; } eventsQueue.Enqueue(Update); }
public void Should_invoke_events_when_pause_between_enqueue() { using (var queue = new ActionsQueue(log)) { var tmp = 1; queue.Enqueue(() => tmp = 2); Action check = () => tmp.Should().Be(2); check.ShouldPassIn(defaultTimeout); Thread.Sleep(defaultTimeout); queue.Enqueue(() => tmp = 3); check = () => tmp.Should().Be(3); check.ShouldPassIn(defaultTimeout); } }
private void StartMultiplayerGame(bool isHost) { Debug.LogFormat("launcher start multiplayer, {0}", isHost); var gameService = new MultiPlayerGameService(isHost, _gameData, _netService); gameService.OnStartGame.Subscribe(_appData.OnStartGame.Dispatch).DisposeBy(this); gameService.OnGameOver.Subscribe(side => _appData.OnGameOver.Dispatch()).DisposeBy(this); _updatable = new NetworkMatch(gameService, _gameView); _appData.OnGameOver.SubscribeOnce(() => { _netService.Close(); }).DisposeBy(this); _mainThreadActions.Enqueue(gameService.StartGame); }
public void Should_handle_events() { using (var queue = new ActionsQueue(log)) { var tmp = false; queue.Enqueue(() => tmp = true); Action action = () => tmp.Should().BeTrue(); action.ShouldPassIn(defaultTimeout); } }
internal void OnCreatedDestroyedStream(SubtConnectedPeerStream stream, bool createdOrDestroyed) { _actionsQueue.Enqueue(() => { if (createdOrDestroyed) { _streams.Add(stream.StreamId, stream); } else { _streams.Remove(stream.StreamId); } }); }
public void Should_not_handle_new_events_after_dispose() { var queue = new ActionsQueue(log); queue.Dispose(); var tmp = false; queue.Enqueue(() => tmp = true); Action action = () => tmp.Should().BeFalse(); action.ShouldNotFailIn(defaultTimeout); }
public void Should_not_handle_enqueued_actions_after_dispose() { var queue = new ActionsQueue(log); var tmp = 1; queue.Enqueue( () => { tmp = 2; Thread.Sleep(defaultTimeout - 100.Milliseconds()); }); queue.Enqueue(() => tmp = 4); Action waitStartAction = () => tmp.Should().Be(2); waitStartAction.ShouldPassIn(50.Milliseconds()); queue.Dispose(); Action action2 = () => tmp.Should().Be(2); action2.ShouldNotFailIn(defaultTimeout + 100.Milliseconds()); }
internal void OnCreatedDestroyedStream(SubtConnectedPeerStream stream, bool createdOrDestroyed) { _actionsQueue.Enqueue(() => { if (createdOrDestroyed) { if (!_streams.ContainsKey(stream.StreamId)) { _streams.Add(stream.StreamId, stream); // todo why does it insert duplicate keys sometimes? } } else { _streams.Remove(stream.StreamId); } }, "subtsender2462"); }
public void Should_not_fail_if_action_throws_exception() { var tmp = 1; Action act = () => { using (var queue = new ActionsQueue(log)) { queue.Enqueue(() => throw new Exception()); queue.Enqueue(() => tmp = 3); Action action = () => tmp.Should().Be(3); action.ShouldPassIn(defaultTimeout); } }; act.Should().NotThrow(); }
private void OnNodeEvent(NodeChangedEventType type, string path) { if (isDisposed) { return; } var parsedPath = pathHelper.TryParse(path); if (parsedPath?.environment == null || parsedPath.Value.application != null) { log.Warn("Received node event of type '{NodeEventType}' on path '{NodePath}': not an environment node.", type, path); return; } // Note(kungurtsev): run in new thread, because we shouldn't block ZooKeeperClient. eventsHandler.Enqueue(() => Update(parsedPath.Value.environment)); }
public void RequestPlugin(Client client, int resourceId) { Logger.Debug("Client CI-{0} requests static command plugin with resource id {1}", client.Id, resourceId); _requests.Enqueue(new DynamicCommandPluginRequest(client, resourceId)); }
public void ActionCreated(object sender, ActionCreatedEventArgs e) { ActionsQueue.Enqueue(e.Action); }
/// <summary> /// Enqueue task continuation /// </summary> /// <param name="continuation">Continuation</param> public void OnCompleted(Action continuation) { _exp.Enqueue(continuation); IsCompleted = true; }
/// <summary> /// Enqueue action to be executed after saving /// </summary> /// <param name="action"></param> public void ContinueWith(Action action) { _exp.Enqueue(action); }
public void EnqueueAction(EntityAction action) { ActionsQueue.Enqueue(action); }