Exemple #1
0
        void handleSetDataResponse(Message.SetDataResponse setDataResponse)
        {
            if (setDataResponse.handshake.authToken != _handshake.authToken)
            {
                return;
            }

            SimCapiSetRequestCallback requestCallback = _setRequests[setDataResponse.simId][setDataResponse.key];

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

            SimCapiQueuedSetRequest queuedSetRequest = requestCallback.queuedSetRequest;

            _setRequests[setDataResponse.simId].Remove(setDataResponse.key);

            if (queuedSetRequest != null)
            {
                setDataRequest(setDataResponse.simId, setDataResponse.key, queuedSetRequest.value, queuedSetRequest.successDelegate, queuedSetRequest.errorDelegate);
            }
        }
Exemple #2
0
        public bool setDataRequest(string simId, string key, string value, SetDataRequestSuccessDelegate successDelegate, SetDataRequestErrorDelegate errorDelegate)
        {
            if (simId == null)
            {
                throw new System.Exception("setDataRequest() called with null simId!");
            }

            if (key == null)
            {
                throw new System.Exception("setDataRequest() called with null key!");
            }

            if (value == null)
            {
                throw new System.Exception("setDataRequest() called with null value!");
            }

            // Use local data fallback
            if (!ExternalCalls.isInIFrame() || ExternalCalls.isInAuthor())
            {
                _simCapiLocalData.setData(simId, key, value, successDelegate);
                return(true);
            }

            // Make sure dictionary exists for simId
            if (_setRequests.ContainsKey(simId) == false)
            {
                _setRequests[simId] = new Dictionary <string, SimCapiSetRequestCallback>();
            }

            // dataRequest in progress, add to queue
            if (_setRequests[simId].ContainsKey(key) == true)
            {
                _setRequests[simId][key].queuedSetRequest = new SimCapiQueuedSetRequest(value, successDelegate, errorDelegate);
                return(false);
            }

            _setRequests[simId][key] = new SimCapiSetRequestCallback(successDelegate, errorDelegate);

            string jsonString = SimCapiJsonMaker.create_SET_DATA_REQUEST(_handshake, key, value, simId);

            if (_handshake.authToken == null)
            {
                _pendingMessagesForHandshake.Add(jsonString);
            }
            else
            {
                sendMessage(jsonString);
            }

            return(true);
        }