private void HandleWorkerMessage(DOMEvent e) { var data = e.As<MessageEvent>().data; var cmd = data.Member("cmd").As<string>(); switch (cmd) { case "preRender": OnPreRender(); break; case "partialRenderFinished": OnPartialRenderFinished(data.Member("result").As<RenderFinishedEventArgs>()); break; case "renderFinished": OnRenderFinished(data.Member("result").As<RenderFinishedEventArgs>()); break; case "postRenderFinished": OnPostRenderFinished(); break; case "error": console.error(data.Member("exception")); break; case "loaded": var score = data.Member("score").As<Score>(); if (score.As<bool>()) { var jsonConverter = new JsonConverter(); score = jsonConverter.JsObjectToScore(score); } _workerApi.TriggerEvent("loaded", score); break; } }
private void ScoreLoaded(Score score) { Score = score; var json = new JsonConverter(); PostMessage(new { cmd = "loaded", score = json.ScoreToJsObject(score) }); Render(); }
private void ScoreLoaded(Score score) { Score = score; if (_includeScoreInLoadedEvent) { var json = new JsonConverter(); PostMessage(new { cmd = "loaded", score = json.ScoreToJsObject(score) }); } else { PostMessage(new { cmd = "loaded" }); } Render(); }