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); } }
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); } }
public void onError(SimCapi.Message.GetDataResponse setDataResponse) { // Error occured value not set }
public void onSuccess(SimCapi.Message.GetDataResponse setDataResponse) { // Value was set successfully }