public void Register() { var regMsg = new Dictionary <string, object>(); regMsg.Add("author", authorName); regMsg.Add("title", title); regMsg.Add("platform", "Unity3D"); byte[] registration = Encoding.UTF8.GetBytes(Json.Serialize(regMsg)); wwwcall = new RequestWWW(); StartCoroutine(wwwcall.doHttpPost(rootServerUrl + "/mesh/register", registration, -1)); }
void Update() { if (wwwcall != null && wwwcall.IsDone && meshKey == 0 && isRegistered == false) { if (wwwcall.Error != null) { Debug.Log("error registering: " + wwwcall.Error); } else { var result = Json.Deserialize(wwwcall.Text) as Dictionary <string, object>; if ((bool)result["result"]) { isRegistered = true; meshKey = (int)((long)result["key"]); meshSlot = (int)((long)result["index"]); } else { isRegistered = false; Debug.Log("Unable to register: " + (string)result["error"]); } } wwwcall = null; } else if (meshKey != 0 && isRegistered == true && needsToSend == true && meshToSend != null) { if (wwwcall == null) { wwwcall = new RequestWWW(); serializer.Serialize(meshToSend); StartCoroutine(wwwcall.doHttpPost(rootServerUrl + "/mesh/" + meshSlot + "/frame", serializer.packet, meshKey)); } else if (wwwcall != null && wwwcall.IsDone) { wwwcall = null; } } }