internal static EngineIOPacket[] Decode(HttpListenerRequest Request) { if (Request != null) { return(Decode(Request.InputStream, Request.ContentType.Equals("application/octet-stream"))); } return(new EngineIOPacket[0]); }
public bool HandleRequest(HttpListenerRequest request, HttpListenerResponse response, string relativePath) { var objectPath = relativePath.Substring(1); Dictionary <string, object> content = null; Exception error = null; var failContent = new Dictionary <string, object>(); UnityMainThreadDispatcher.Instance().EnqueueAndWait(() => { try { if (objectPath == "") { content = SceneExplorer.InspectRoot(); } else { var gameObject = GameObject.Find(objectPath); if (gameObject == null) { error = new ObjectNotFoundException(objectPath); return; } content = SceneExplorer.InspectGameObject(gameObject); var idString = request.QueryString.Get("id"); var componentId = 0; var findTargetId = !string.IsNullOrEmpty(idString) && int.TryParse(idString, out componentId); if (findTargetId) { content["component"] = SceneExplorer.CreateRemoteView(gameObject .GetComponents <Component>() .First(comp => comp.GetInstanceID() == componentId)); } } } catch (Exception exception) { error = exception; } }); if (error != null) { response.SendJson(JsonReponse.Error(error.Message)); } else if (failContent.Count > 0) { response.SendJson(JsonReponse.Fail(failContent)); } else { response.SendJson(JsonReponse.Success(content)); } return(true); }