Example #1
0
    private void Post <T, S>(string pJsn, ReceiveRecordDelegateList <T> pReceiveSuccessGoesHere, ReceiveRecordDelegate <S> pReceiveFailGoesHere)
    {
        UnityWebRequest lcWebReq = jsnWebRequest(pJsn);

        // VERY WEIRD, because Send returns an object that
        // you then add a "completed" event handler to the
        // completed listeners
        var lcAsyncOp = lcWebReq.SendWebRequest();

        lcAsyncOp.completed += (x => {
            Debug.Log("RETURNED FROM JsnDROP:" + lcWebReq.downloadHandler.text);
            string lcStrJsnReceived = lcWebReq.downloadHandler.text;
            string lcJsnMsgArray = "";

            // THIS IS LOOKING MESSY!!
            S jsnAsTypeS = JsonUtility.FromJson <S>(lcStrJsnReceived);
            JsnReceiver jsnReceived = jsnAsTypeS as JsnReceiver;
            List <T> receivedList;
            switch (jsnReceived.JsnMsg)
            {
            case "SUCCESS.ALL":
            case "SUCCESS.SELECT":
                lcJsnMsgArray = GetArrayFromMsg(lcStrJsnReceived);

                receivedList = FromJsonArrayToList <T>(lcJsnMsgArray);
                Debug.Log("Post<T,S> LIST length is " + receivedList.Count().ToString());
                pReceiveSuccessGoesHere(receivedList);
                break;

            default:
                pReceiveFailGoesHere(jsnAsTypeS);
                break;
            }
        });
    }
Example #2
0
    }//Store

    #endregion

    #region SELECT records WHERE
    public void Select <T, S>(string pStrWhere, ReceiveRecordDelegateList <T> pReceiveSuccessGoesHere, ReceiveRecordDelegate <S> pReceiveFailGoesHere)
    {
        try
        {
            string tblName   = typeof(T).ToString();
            string jsnString = "{\"SELECT\":\"" + tblName + "\",\"WHERE\":\"" + pStrWhere + "\"}";
            Post <T, S>(jsnString, pReceiveSuccessGoesHere, pReceiveFailGoesHere);
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }//SELECT WHERE
Example #3
0
    }//Store

    #endregion
    #region retrieve ALL records
    public void All <T, S>(ReceiveRecordDelegateList <T> pReceiveSuccessGoesHere, ReceiveRecordDelegate <S> pReceiveFailGoesHere)
    {
        try
        {
            string tblName   = typeof(T).ToString();
            string jsnString = "{\"ALL\":\"" + tblName + "\"}";
            Post <T, S>(jsnString, pReceiveSuccessGoesHere, pReceiveFailGoesHere);
        }
        catch (Exception ex)
        {
            throw (ex);
        }
    }//Store
Example #4
0
    public void PutJsonList <T>(List <T> pRecordList, string pStrURI, ReceiveRecordDelegateList <T> pDelReceiveRecordList)
    {
        string strJSONURI = pStrURI + "?put=" + ListToJson <T>(pRecordList);

        System.Uri lcURI = new System.Uri(strJSONURI);

        UnityWebRequest lcWebReq = new UnityWebRequest(lcURI, "GET")
        {
            downloadHandler = new DownloadHandlerBuffer(),
        };

        var lcAsyncOp = lcWebReq.SendWebRequest();

        lcAsyncOp.completed += (x => {
            string lcText = lcWebReq.downloadHandler.text;
            GameModel.DebugDisplay = "COMPLETED " + lcText;

            List <T> lcList = FromJsonArrayToList <T>(lcText);

            pDelReceiveRecordList(lcList);
        });
    }