public async Task StartInteraction(StartInteractionSendJsonData json, Action <bool, StartInteractionReceiveJsonData> callback) { StartInteractionReceiveJsonData data; if (!useServer) { //data = new StartInteractionReceiveJsonData(); //callback(true, data); return; } string sendJson = JsonUtility.ToJson(json); string url; if (!useMocky) { //Debug.Log("Using actual server url..."); url = "http://" + ip + port + interactionServletUrl + "startInteraction"; } else { //Debug.Log("Using mocky url..."); return; } var r = await LoadPostUrl(url, sendJson, (request) => { if (string.IsNullOrEmpty(request.error)) { string result = request.text.Trim(); data = JsonUtility.FromJson <StartInteractionReceiveJsonData>(result); //Debug.Log("myresult: " + result); if (data.error.error_code == ERROR_CODE_200) { callback(true, data); } else { callback(false, data); } } else { //WriteError(request, "StartInteraction"); data = new StartInteractionReceiveJsonData(); callback(false, data); } }); //Debug.Log(r); }
public static async Task RunStartInteraction() { StartInteractionSendJsonData sJson = new StartInteractionSendJsonData { deviceID = DEVICEID, }; await TrinaxManager.trinaxAsyncServerManager.StartInteraction(sJson, (bool success, StartInteractionReceiveJsonData rJson) => { if (success) { if (!string.IsNullOrEmpty(rJson.data)) { TrinaxGlobal.Instance.userData.interactionID = rJson.data; Debug.Log("Started interaction!"); } } else { Debug.Log("Error in <StartInteraction> API!"); } }); }