public void Process_WithFollowingStage() { var stage1 = ProcessingPipelineStage.Create <ProcessingPipelineTestStage>("Stage1", null); var stage2 = stage1.AddNextStage <ProcessingPipelineTestStage>("Stage2"); // initialize the stages Assert.False(stage1.IsInitialized); Assert.False(stage2.IsInitialized); stage1.Initialize(); Assert.True(stage1.IsInitialized); Assert.True(stage2.IsInitialized); // process a log message var message = MessagePool.GetUninitializedMessage(); Assert.False(stage1.ProcessSyncWasCalled); Assert.False(stage2.ProcessSyncWasCalled); stage1.ProcessMessage(message); Assert.True(stage1.ProcessSyncWasCalled); Assert.True(stage2.ProcessSyncWasCalled); Assert.Same(message, stage1.MessagePassedToProcessSync); Assert.Same(message, stage2.MessagePassedToProcessSync); // shut the stages down stage1.Shutdown(); Assert.False(stage1.IsInitialized); Assert.False(stage2.IsInitialized); }
public void Process_WithFollowingStage() { var stage1 = ProcessingPipelineStage.Create <AsyncProcessingPipelineTestStage>("Stage1", null); var stage2 = stage1.AddNextStage <AsyncProcessingPipelineTestStage>("Stage2"); // initialize the stages Assert.False(stage1.IsInitialized); Assert.False(stage2.IsInitialized); stage1.Initialize(); Assert.True(stage1.IsInitialized); Assert.True(stage2.IsInitialized); // process a log message var message = MessagePool.GetUninitializedMessage(); Assert.False(stage1.ProcessSyncWasCalled); Assert.False(stage2.ProcessSyncWasCalled); Assert.False(stage1.ProcessAsyncWasCalled); Assert.False(stage2.ProcessAsyncWasCalled); stage1.ProcessMessage(message); Assert.True(stage1.ProcessSyncWasCalled); Assert.True(stage2.ProcessSyncWasCalled); Assert.Same(message, stage1.MessagePassedToProcessSync); Assert.Same(message, stage2.MessagePassedToProcessSync); // give the processing threads time to call ProcessAsync() Thread.Sleep(500); Assert.True(stage1.ProcessAsyncWasCalled); Assert.True(stage2.ProcessAsyncWasCalled); Assert.Single(stage1.MessagesPassedToProcessAsync); Assert.Single(stage2.MessagesPassedToProcessAsync); Assert.Same(message, stage1.MessagesPassedToProcessAsync.First()); Assert.Same(message, stage2.MessagesPassedToProcessAsync.First()); }
/// <summary> /// Imports all the Messages /// </summary> private static MessagePool ImportMessages(XmlDocument xml) { MessagePool pool = new MessagePool(); ImportMessageType(xml, pool, MessageType.LOOK_AT_GIRL, Tags.MESSAGE_LOOK_AT); ImportMessageType(xml, pool, MessageType.PAIN_DOWN, Tags.MESSAGE_PAIN_DOWN); ImportMessageType(xml, pool, MessageType.PICKUP_IMPL, Tags.MESSAGE_PICKUP_IMPLEMENT); ImportMessageType(xml, pool, MessageType.ENTER_IMPL, Tags.MESSAGE_ENTER_WITH_IMPLEMENT); ImportMessageType(xml, pool, MessageType.SWAP_IMPL, Tags.MESSAGE_SWAP_IMPLEMENT); ImportMessageType(xml, pool, MessageType.SWAP_WORSE_IMPL, Tags.MESSAGE_SWAP_WORSE); ImportMessageType(xml, pool, MessageType.DROP_IMPL, Tags.MESSAGE_DROP_IMPLEMENT); ImportMessageType(xml, pool, MessageType.HOLDING_ANNOUNCE, Tags.MESSAGE_HOLDING_ANNOUNCE); ImportMessageType(xml, pool, MessageType.HOLDING_REACT_ANNOUNCE, Tags.MESSAGE_HOLDING_ANNOUNCE_REACT); ImportMessageType(xml, pool, MessageType.HOLDING_WATCH_ANNOUNCE, Tags.MESSAGE_HOLDING_ANNOUNCE_WATCH); ImportMessageType(xml, pool, MessageType.HOLDING_START, Tags.MESSAGE_HOLDING_START); ImportMessageType(xml, pool, MessageType.HOLDING_START_REACT, Tags.MESSAGE_HOLDING_START_REACT); ImportMessageType(xml, pool, MessageType.HOLDING_START_WATCH, Tags.MESSAGE_HOLDING_START_WATCH); ImportMessageType(xml, pool, MessageType.DRAG, Tags.MESSAGE_HOLDING_DRAG); ImportMessageType(xml, pool, MessageType.DRAG_REACT, Tags.MESSAGE_HOLDING_DRAG_REACT); ImportMessageType(xml, pool, MessageType.DRAG_WATCH, Tags.MESSAGE_HOLDING_DRAG_WATCH); ImportMessageType(xml, pool, MessageType.HOLDING_STOP, Tags.MESSAGE_HOLDING_STOP); ImportMessageType(xml, pool, MessageType.HOLDING_STOP_REACT, Tags.MESSAGE_HOLDING_STOP_REACT); ImportMessageType(xml, pool, MessageType.HOLDING_STOP_WITHOUT_DRAG, Tags.MESSAGE_HOLDING_STOP_WITHOUTDRAG); return(pool); }
public void Process_Standalone(bool processSyncReturnValue) { var callback = new Callback { ProcessSyncCallbackReturnValue = processSyncReturnValue }; var stage = ProcessingPipelineStage.Create <CallbackPipelineStage>("Callback", null); stage.ProcessingCallback = callback.ProcessSyncCallback; // initialize the stage Assert.False(stage.IsInitialized); stage.Initialize(); Assert.True(stage.IsInitialized); // process a log message var message = MessagePool.GetUninitializedMessage(); Assert.False(callback.ProcessSyncCallbackWasCalled); stage.ProcessMessage(message); Assert.True(callback.ProcessSyncCallbackWasCalled); Assert.Same(message, callback.MessagePassedToProcessSyncCallback); // shut the stage down stage.Shutdown(); Assert.False(stage.IsInitialized); }
private async Task SendPump(CancellationToken cancellation) { using (var session = this.serializerSessionPool.GetSession()) { while (!cancellation.IsCancellationRequested && await this.outgoingReader.WaitToReadAsync(cancellation)) { while (this.outgoingReader.TryRead(out var item)) { WriteMessage(item, session); if (item.Body is IDisposable disposable) { disposable.Dispose(); } MessagePool.Return(item); session.PartialReset(); var flushResult = await this.connection.Output.FlushAsync(cancellation); if (flushResult.IsCanceled || flushResult.IsCompleted) { return; } } } } void WriteMessage(Message message, SerializerSession session) { var writer = new Writer <PipeWriter>(this.connection.Output, session); this.messageSerializer.Serialize(ref writer, message); } }
public override void Send(Movement movement) { OutgoingMessage msg = MessagePool.CreateMessage(); movement.Write(msg); Broadcast(msg); }
public override void ClientHandleMessageFromServer(NetMessageType messageType, byte[] buffer) { // if message from server to clients if (messageType == NetMessageType.VRBodyUpdateS2C) { var msg = MessagePool.Get <VRBodyUpdateS2CMessage>(buffer); var remotePlayer = NetServices.playerManager.players.GetValueOrDefault(msg.netId); if (remotePlayer != null) { var bodyData = new VRBodyUpdateData() { position = msg.position, //RemotePos(senderPlayer.netId, msg.position), headPosition = msg.headPosition, headRotation = msg.headRotation, leftHandPosition = msg.leftHandPosition, leftHandRotation = msg.leftHandRotation, rightHandPosition = msg.rightHandPosition, rightHandRotation = msg.rightHandRotation }; (remotePlayer as NetPlayerBase).GetComponent <VRBodyUpdateSync>().HandleUpdate(bodyData); } MessagePool.Return(msg); } }
public override void OnCreate() { base.OnCreate(); pool = new MessagePool(); carousel.Factory = this; carousel.onVisibleElementsChanged += OnVisibleElementsChanged; btnRequestHelp.gameObject.SetActive(ViewModel.InGuild); btnRequestHelp.onClick.AddListener(OnHelpRequestButtonClicked); btnChatTab.onValueChanged.AddListener(OnClickChatTab); btnIncomingTab.onValueChanged.AddListener(OnClickIncomingTab); btnOpenGuildDialog.onClick.AddListener(() => OpenGuildDialog(DialogGuildsViewModel.EContentCases.Join)); _hidePos = window.anchoredPosition.x; InitCloseButton(); InitInputField(); var scenario = Use <IGuiManager>().CreateView <WaitingOpenMarketScreenScenario>(); scenario.dialogToClose = this; Use <IScenarioService>().StartScenario(scenario); ViewModel.ShowChatMessage(); carousel.GotoLastPackMessage(); }
private void Awake() { pool = new MessagePool(); received = new LockFreeQueue <ReferenceCountedMessage>(); pc = GetComponentInParent <WebRtcPeerConnection>(); id = -1; }
public override void ServerHandleMessageFromClient(NetMessageType messageType, byte[] buffer, short clientPlayerNetId) { // if message is from a client to server if (messageType == NetMessageType.VRBodyUpdateC2S) { var senderPlayer = NetServices.playerManager.players.GetValueOrDefault(clientPlayerNetId); if (senderPlayer != null) { // deserialize message and have the player sync script handle it further var msg = MessagePool.Get <VRBodyUpdateC2SMessage>(buffer); var bodyData = new VRBodyUpdateData() { position = msg.position, //ServerPos(senderPlayer.netId, msg.position), headPosition = msg.headPosition, headRotation = msg.headRotation, leftHandPosition = msg.leftHandPosition, leftHandRotation = msg.leftHandRotation, rightHandPosition = msg.rightHandPosition, rightHandRotation = msg.rightHandRotation }; // this smells like bad performance. but it keeps dependencies separate. // perhaps instead of GetComponent<> it can be optimized via some local VRPlayerManager that handles references of VR components on all players. // every new system which has dependencies on previous systems can use this paradigm: a manager with references to connect the dependency to the new system, for efficiency, without compromising the dependency. // for now we use the shitty method below because there are bigger bottlenecks (senderPlayer as NetPlayerBase).GetComponent <VRBodyUpdateSync>().HandleUpdate(bodyData); MessagePool.Return(msg); } } }
public bool DisconnectClient(AuthClient newClient) { bool succes = false; AuthClient client = AuthServer.Instance.GetClients().Find(x => x.Account != null && x.Account.Id == newClient.Account.Id); if (client != null) { client.Disconnect(); succes = true; } else { if (newClient.Account.LastSelectedServerId != 0) { TransitionClient server = TransitionServer.Instance.GetServerClient(newClient.Account.LastSelectedServerId); var serverData = ServerRecord.GetWorldServer(newClient.Account.LastSelectedServerId); if (server != null && server.IsConnected && serverData != null && serverData.Status != ServerStatusEnum.STARTING) // Online { MessagePool.SendRequest <DisconnectClientResultMessage>(server, new DisconnectClientRequestMessage { AccountId = newClient.Account.Id, }, delegate(DisconnectClientResultMessage message) { succes = message.IsSucces; }, delegate() { this.OnTransitionFailed(newClient); }); } else { succes = false; } } } return(succes); }
/// <summary> /// 判断Id是否为空 有就修改没有就添加 /// </summary> /// <param name="input"></param> /// <returns></returns> public bool CreateMessagePool(CreateMessagepoolInput input) { bool result = false; MessagePool pool = new MessagePool(); pool.Id = input.Id; pool.PlatForm = input.PlatForm; pool.ModelName = input.ModelName; pool.OrtherMsg = input.OrtherMsg; pool.Operation = input.Operation; pool.JsonText = input.JsonText; pool.Status = 0; pool.ResultText = input.ResultText; var resultdata = _messagePool.Insert(pool); if (!string.IsNullOrWhiteSpace(resultdata.ToString())) { result = true; } return(result); //if (true) //{ // if (input.PoolInfo.Id.HasValue) // { // await UpdateMessagepool(input); // } // else // { // await AddMessagePool(input); // } //} }
public void Get_should_produce_new_message() { var pool = new MessagePool <DummyMessage>(); IMessage d = pool.Get(); Assert.NotNull(d); }
private void GrabController_OnGrabNothing(ControllerGrabberData controller, IHandleGrabbing grabbedObj) { if (NetServices.isNetworked && NetServices.isClient) { // spawn! // or if networked, ask server for permission to spawn. // also give spawn request feedback, and success/fail feedback... but in separate feedback class. var msgReq = MessagePool.Get <SpawnGrabRequestMessage>(); msgReq.isLeft = controller.isLeft; msgReq.prefabType = GetSpawnType(controller.isLeft); ClientNetSender.instance.Send(msgReq, UnityEngine.Networking.QosType.ReliableSequenced); MessagePool.Return(msgReq); } else if (!NetServices.isNetworked) { // spawn! but beware: it might get out of sync with server... so upon reconnect, all those objects must be destroyed or re-synced! :( how the f**k to do that??? var newObj = PrefabManager.instance.Spawn(prefabType, controller.grabPointGO.transform.position, controller.grabPointGO.transform.rotation); var grabber = newObj.gameObject.GetComponent <IHandleGrabbing>(); if (grabber != null) { controller.Grab(grabber); } Debug.Log("<color=#aa6000>Spawned non-synced object</color>", newObj.gameObject); } }
public void CheckMessagePooledError() { try { var dummyMessage = new Message("Message for testing"); dummyMessage.ReturnToPool(); InvalidOperationException?expectedException = null; try { dummyMessage.EnsureCapacity(500); } catch (InvalidOperationException ex) { expectedException = ex; } Assert.IsNotNull(expectedException); } finally { // Cleanup MessagePool.Clear(); } }
private void ProcessBusinessAlert(MessageRuleByCompany rule) { //Console.WriteLine("Entre BA"); try { //Si se vencio el next runtime lo ejecute if (rule.NextRunTime != null && rule.NextRunTime > DateTime.Now) { return; } //Sace el data set y guarda el resultado en Message Pool MessagePool msg = new MessagePool { CreationDate = DateTime.Now, CreatedBy = WmsSetupValues.SystemUser }; //Console.WriteLine("Get Message"); msg.Message = GetBusinessAlertMessage(rule); //Console.WriteLine("Message: " + msg.Message); if (string.IsNullOrEmpty(msg.Message)) { return; } msg.Entity = new ClassEntity { ClassEntityID = EntityID.BusinessAlert }; msg.IsHtml = rule.IsHtml; msg.MailFrom = rule.MailFrom; msg.MailTo = rule.MailTo; msg.Subject = rule.Template.Name; msg.AlreadySent = false; msg.Rule = rule; //Save the record. //Console.WriteLine("Saving BA:"); Factory.DaoMessagePool().Save(msg); //Setea el next runtime rule.NextRunTime = DateTime.Now.AddSeconds(rule.FrequencyNumber * rule.FrequencyType); rule.LastUpdate = DateTime.Now; Factory.DaoMessageRuleByCompany().Update(rule); } catch (Exception ex) { Console.WriteLine(ex.Message); ExceptionMngr.WriteEvent(" BusinessAlert:" + rule.RuleName, ListValues.EventType.Fatal, ex, null, ListValues.ErrorCategory.Messages); } }
public static MessagePool GetInstance() { if (theOnlyInstanceOfMessageBroker == null) { theOnlyInstanceOfMessageBroker = new MessagePool(); } return(theOnlyInstanceOfMessageBroker); }
public static void HandleCharacterCreation(CharacterCreationRequestMessage message, WorldClient client) { if (!WorldServer.Instance.IsStatus(ServerStatusEnum.ONLINE)) { client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_NO_REASON)); return; } if (!client.InGame) { if (client.Characters.Count() == client.Account.CharacterSlots) { client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_TOO_MANY_CHARACTERS)); return; } if (CharacterRecord.NameExist(message.name)) { client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_NAME_ALREADY_EXISTS)); return; } if (client.Account.Role < ServerRoleEnum.Animator) { foreach (var value in message.name) { if (UnauthorizedNameContent.Contains(value)) { client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_INVALID_NAME)); return; } } } if (message.name.Split(null).Count() > 1) { client.Send(new CharacterCreationResultMessage((sbyte)CharacterCreationResultEnum.ERR_INVALID_NAME)); return; } long nextId = CharacterRecord.Characters.DynamicPop(x => x.Id); MessagePool.SendRequest <OnCharacterCreationResultMessage>(TransitionServerManager.Instance.AuthServer, new OnCharacterCreationMessage { AccountId = client.Account.Id, CharacterId = nextId, }, delegate(OnCharacterCreationResultMessage result) { CreateCharacter(message, client, result.Succes, nextId); }); } }
public void Get_should_produce_same_message() { var pool = new MessagePool <DummyMessage>(); IMessage d = pool.Get(); d.Sent(); IMessage q = pool.Get(); Assert.AreEqual(d, q); }
public MessageQueue(MessageModule module) { nodePool = new StablePriorityQueueNodePool(); excuteMap = new Dictionary <StablePriorityQueueNode, Message>(); _pool = new MessagePool(); _queue = new StablePriorityQueue <StablePriorityQueueNode>(); _list = new List <StablePriorityQueueNode>(); _tmp = new Queue <Message>(); this.module = module; }
public override void ServerHandleMessageFromClient(NetMessageType messageType, byte[] buffer, short clientPlayerNetId) { switch (messageType) { case NetMessageType.Grab: { var msg = MessagePool.Get <GrabMessage>(buffer); var player = NetServices.playerManager.GetPlayer(msg.netId); if (player != null) { RigidbodySyncComponent rbc = RbSyncManager.instance.Get(msg.syncId); if (rbc != null) { var grabSystem = player.gameObject.GetComponent <VRPlayerGrabSystem>(); var cgd = grabSystem.GetControllerGrabberData(msg.leftHand); cgd.Grab(rbc.GetComponent <IHandleGrabbing>()); rbc.StopUpdating(cgd.controller); ServerNetSender.instance.SendToAll(msg, UnityEngine.Networking.QosType.ReliableSequenced, msg.netId); } } MessagePool.Return(msg); break; } case NetMessageType.Throw: { var msg = MessagePool.Get <ThrowMessage>(buffer); var player = NetServices.playerManager.GetPlayer(msg.netId); if (player != null) { RigidbodySyncComponent rbc = RbSyncManager.instance.Get(msg.syncId); if (rbc != null) { var grabSystem = player.gameObject.GetComponent <VRPlayerGrabSystem>(); var cgd = grabSystem.GetControllerGrabberData(msg.leftHand); cgd.Ungrab(); rbc.ContinueUpdating(cgd.controller); var rb = rbc.rigidbody; rb.position = msg.position; rb.rotation = msg.rotation; rb.velocity = msg.velocity; rb.maxAngularVelocity = Mathf.Max(rb.maxAngularVelocity, msg.angularVelocity.magnitude); rb.angularVelocity = msg.angularVelocity; // send to clients now ServerNetSender.instance.SendToAll(msg, UnityEngine.Networking.QosType.ReliableSequenced, msg.netId); } } MessagePool.Return(msg); break; } } }
/// <summary> /// 构造函数 /// </summary> public KeepSocketClient(string id) { if (_ClientMap.ContainsKey(id)) { logger.Fatal("长连接服务 ID 已存在,程序将不可使用,请联系管理员重新配置程序。"); return; } _ClientId = id; _MessagePool = new AsyncMessagePool(); _ClientMap.Add(id, this); }
public IList <MessagePool> Select(MessagePool data) { IList <MessagePool> datos = new List <MessagePool>(); datos = GetHsql(data).List <MessagePool>(); if (!Factory.IsTransactional) { Factory.Commit(); } return(datos); }
protected void OnClearClick(object sender, EventArgs e) { // add some back to message pool foreach (GameMessage msg in DataSource) { MessagePool.PushFree(msg); } // now clear DataSource.Clear(); }
private void Introduce(RemoteConnection remote, IPEndPoint endPoint) { Debug.Log("NATServer: Introducing: ", endPoint.ToString(), " to: ", remote.EndPoint.ToString()); OutgoingMessage message = MessagePool.CreateMessage(); message.Write(NATMessageType.INTRODUCTION); message.Write(endPoint); remote.Send(message); MessagePool.Recycle(message); }
private void ProcessMessageObject(Object obj, Int32 rID, string rCode, MessageRuleByCompany rule, short EntityTypeID) { try { //lista de Mappings IList <LabelMapping> listMap = Factory.DaoLabelMapping().Select( new LabelMapping { LabelType = new DocumentType { DocTypeID = LabelType.Message } }); if (listMap != null && listMap.Count > 0) { MessagePool msg = GenerateMessage(listMap, rule.Template, obj); if (!string.IsNullOrEmpty(rule.Template.DetailQuery)) { msg.Message += AddDocumentDetails(rule, rID, rCode); } //Revisa si hay rule extension que adicionan informacion al mensaje if (rule.RuleExtensions != null && rule.RuleExtensions.Count > 0) { msg.Message += AddRuleExtension(rule, rID); } //Campos Faltantes msg.RecordID = rID; msg.Entity = new ClassEntity { ClassEntityID = EntityTypeID }; msg.IsHtml = rule.IsHtml; msg.MailFrom = rule.MailFrom; msg.MailTo = rule.MailTo; //Si el objeto es un documento de tipo sales Shipment y esta la //Variable de sent notification to customers se va el mail. if (obj.GetType().Equals(typeof(Document))) { msg.MailTo += GetAccountAddress((Document)obj); } msg.AlreadySent = false; msg.Rule = rule; //Save the record. Factory.DaoMessagePool().Save(msg); } } catch { } }
// Param == connection to be introduced public void Introduce(NATRemote conn) { Debug.Log("NATServer: Introducing: ", conn.Remote.EndPoint.ToString(), " to: ", Remote.EndPoint.ToString()); OutgoingMessage message = MessagePool.CreateMessage(); message.Write(NATMessageType.INTRODUCTION); message.Write(conn.Remote.EndPoint); Remote.Send(message); MessagePool.Recycle(message); }
/// <summary> /// Obains a new Message for <code>TMessage</code> this can be a new Message a unused /// Message from the internal pool /// </summary> /// <typeparam name="TMessage">Type of data the message should wrap</typeparam> /// <returns>a (new) Message that can be used</returns> public static Message <TMessage> GetMessage <TMessage>() { Message <TMessage> message = MessagePool.GetMessage <TMessage>(); if (message == null) { message = new Message <TMessage>(); message._inUse = true; MessagePool.AddMessage <TMessage>(message); } return(message); }
public int AddMessagePool(MessagePoolDto messagePoolDto) { var messagePool = new MessagePool { iMessageID = messagePoolDto.MessageId, iPoolID = messagePoolDto.PoolId }; Uow.MessagePools.Add(messagePool); Uow.Commit(); return messagePool.iMessagePoolID; }
/// <summary> /// Sends a message to a remote connection /// </summary> public void InformPunchthroughSuccess() { OutgoingMessage request = MessagePool.CreateMessage(); request.Write(NATMessageType.NAT_PUNCH_SUCCESS); fixed(byte *bytes = request.Data) { ENet.MicroSend(Peer, 0, bytes, (IntPtr)request.ByteCount, DeliveryMethod.Reliable); } MessagePool.Recycle(request); }
public void AddAndGet_OneMessage_ReturnsSameMessage() { MessagePool <StringMsg> pool = new MessagePool <StringMsg>(); const string firstMessageContents = "first message"; StringMsg str1 = new StringMsg(firstMessageContents); pool.AddMessage(str1); StringMsg str2 = pool.GetOrCreateMessage(); StringMsg str3 = pool.GetOrCreateMessage(); Assert.AreEqual(str1, str2); Assert.AreNotEqual(str2, str3); }
public MessageArguments(MessagePool messageCollection) { this._messageCollection = messageCollection; }
/// <summary> /// Entry point for the application /// </summary> /// <param name="args"></param> public static void Main(string[] args) { // Create the message pool MessagePool pool = new MessagePool(); // Create the root actor Actor root = new Actor(pool); // Attach core systems root.AddComponent<UserInputHandler>(); root.AddComponent<Renderer>(); root.AddComponent<MaterialSystem>(); root.AddComponent<SceneManager>(); root.AddComponent<SceneLoader>(); root.AddComponent<Sleeper>().TargetFPS = 60.0f; // Attach exit listener bool exit = false; Listener<ExitMessage> exitlistener = root.AddComponent<Listener<ExitMessage>>() as Listener<ExitMessage>; exitlistener.OnMessageReceived += (msg) => exit = true; // Initialise root.Init(); // Send the initialise message InitialiseMessage initmsg = new InitialiseMessage(); pool.SendMessage(initmsg); // Load the scene if (!root.GetComponent<SceneLoader>().LoadSceneFromFile("scene.json")) { Console.WriteLine("Failed to load scene!"); Console.ReadKey(); return; } // Setup the frame message FrameMessage framemsg = new FrameMessage(); framemsg.FrameNumber = 0; framemsg.DeltaTime = 0.0f; // Setup the timer Stopwatch frametimer = new Stopwatch(); // Loop until done while (!exit) { // Send frame message frametimer.Start(); pool.SendMessage(framemsg); frametimer.Stop(); framemsg.DeltaTime = (float)frametimer.Elapsed.TotalSeconds; frametimer.Reset(); // Increase frame number framemsg.FrameNumber++; // Process windows events Application.DoEvents(); } // Send the shutdown message ShutdownMessage shutdownmsg = new ShutdownMessage(); pool.SendMessage(shutdownmsg); // Delete root actor and clean up root.Destroy(true); }