コード例 #1
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);
        }
コード例 #2
0
 public SimCapiSetRequestCallback(SetDataRequestSuccessDelegate successDelegate, SetDataRequestErrorDelegate errorDelegate)
 {
     this.successDelegate = successDelegate;
     this.errorDelegate   = errorDelegate;
 }
コード例 #3
0
 public SimCapiQueuedSetRequest(string value, SetDataRequestSuccessDelegate successDelegate, SetDataRequestErrorDelegate errorDelegate)
 {
     this.value           = value;
     this.successDelegate = successDelegate;
     this.errorDelegate   = errorDelegate;
 }
コード例 #4
0
 /// <summary>
 /// Sets a persisent value.
 /// </summary>
 /// <param name="key"></param>
 /// <param name="value"></param>
 /// <param name="onSuccess"></param>
 /// <param name="onError"></param>
 public void Set(string key, string value, SetDataRequestSuccessDelegate onSuccess, SetDataRequestErrorDelegate onError)
 {
     Sim.Capi.Transporter.setDataRequest(Capi.SIM_ID, key, value, onSuccess, onError);
 }