示例#1
0
        void handleGetDataResponse(Message.GetDataResponse getDataResponse)
        {
            if (getDataResponse.handshake.authToken != _handshake.authToken)
            {
                return;
            }

            SimCapiGetRequestCallback requestCallBack = _getRequests[getDataResponse.simId][getDataResponse.key];

            if (getDataResponse.responseType == "success" && requestCallBack.successDelegate != null)
            {
                requestCallBack.successDelegate(getDataResponse);
            }
            else if (getDataResponse.responseType == "error" && requestCallBack.errorDelegate != null)
            {
                requestCallBack.errorDelegate(getDataResponse);
            }

            SimCapiQueuedGetRequest queuedGetRequest = requestCallBack.queuedGetRequest;

            _getRequests[getDataResponse.simId].Remove(getDataResponse.key);

            if (queuedGetRequest != null)
            {
                getDataRequest(getDataResponse.simId, getDataResponse.key, queuedGetRequest.successDelegate, queuedGetRequest.errorDelegate);
            }
        }
示例#2
0
        public void getData(string simId, string key, GetDataRequestSuccessDelegate successDelegate, GetDataRequestErrorDelegate errorDelegate)
        {
            string dataReturnString = ExternalCalls.getKeyPairSessionStorage(simId, key);

            // returns json string defined as below

            /*
             *  var response =
             *  {
             *      success: true,
             *      key: javaKey,
             *      value: null,
             *      exists: false
             *  };
             */

            // Parse return string from external call
            JObject jObject = JsonConvert.DeserializeObject <JObject>(dataReturnString);

            JProperty propSuccess = jObject.Property("success");
            //JProperty propKey = jObject.Property("key");
            JProperty propValue  = jObject.Property("value");
            JProperty propExists = jObject.Property("exists");

            bool success = propSuccess.Value.ToObject <bool>();


            Message.GetDataResponse getDataResponse = new Message.GetDataResponse();
            getDataResponse.handshake = Transporter.getInstance().getHandshake();
            getDataResponse.simId     = simId;
            getDataResponse.key       = key;
            getDataResponse.value     = null;
            getDataResponse.exists    = propExists.ToObject <bool>();

            if (success == true)
            {
                getDataResponse.responseType = "success";
            }
            else
            {
                getDataResponse.responseType = "error";
            }

            if (propValue.Value != null)
            {
                getDataResponse.value = propValue.Value.ToObject <string>();
            }

            if (success == true)
            {
                successDelegate(getDataResponse);
            }
            else
            {
                errorDelegate(getDataResponse);
            }
        }
示例#3
0
 public void onError(SimCapi.Message.GetDataResponse setDataResponse)
 {
     // Error occured value not set
 }
示例#4
0
 public void onSuccess(SimCapi.Message.GetDataResponse setDataResponse)
 {
     // Value was set successfully
 }