Exemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        MyTransporter = SimCapi.Transporter.getInstance();

        MyTransporter.notifyOnReady();

        MyCAPIData = new SimCAPIExposeData();
    }
Exemplo n.º 2
0
        public static Transporter getInstance()
        {
            if (_singleton == null)
            {
                _singleton = new Transporter(new IFramePipe());
            }

            return(_singleton);
        }
Exemplo n.º 3
0
        public void updateValue()
        {
            if (_pointArrayChangedDelegate != null)
            {
                _pointArrayChangedDelegate(_pointList.ToArray(), ChangedBy.SIM);
            }

            Transporter.getInstance().getModel().exposedValueChanged(this, new StringData(arrayToString()));
        }
Exemplo n.º 4
0
        public void updateValue()
        {
            if (_stringArrayChangedDelegate != null)
            {
                _stringArrayChangedDelegate(_values.ToArray(), ChangedBy.SIM);
            }

            Transporter.getInstance().getModel().exposedValueChanged(this, new ArrayData(_values.ToArray()));
        }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        public void unexpose()
        {
            if (_exposedName == null)
            {
                return;
            }

            Transporter.getInstance().getModel().unexposeValue(_exposedName);

            _exposedName = null;
        }
Exemplo n.º 7
0
        public void setValue(float value)
        {
            if (_value == value)
            {
                return;
            }

            _value = value;

            if (_numberChangedDelegate != null)
            {
                _numberChangedDelegate(_value, ChangedBy.SIM);
            }

            Transporter.getInstance().getModel().exposedValueChanged(this, new NumberData(_value));
        }
Exemplo n.º 8
0
        public void setValue(string value)
        {
            if (_value == value)
            {
                return;
            }

            _value = value;

            if (_mathExpressionChangedDelegate != null)
            {
                _mathExpressionChangedDelegate(_value, ChangedBy.SIM);
            }

            Transporter.getInstance().getModel().exposedValueChanged(this, new StringData(_value));
        }
Exemplo n.º 9
0
        public void setValue(T value)
        {
            if ((int)(object)_value == (int)(object)value)
            {
                return;
            }

            _value = value;

            if (_enumChangedDelegate != null)
            {
                _enumChangedDelegate(_value, ChangedBy.SIM);
            }

            Transporter.getInstance().getModel().exposedValueChanged(this, new StringData(_value.ToString()));
        }
Exemplo n.º 10
0
        public void setValue(bool value)
        {
            if (_value == value)
            {
                return;
            }

            _value = value;

            if (_booleanChangedDelegate != null)
            {
                _booleanChangedDelegate(_value, ChangedBy.SIM);
            }

            Transporter.getInstance().getModel().exposedValueChanged(this, new BoolData(_value));
        }
Exemplo n.º 11
0
        public override void expose(string name, bool isReadonly, bool isWriteonly)
        {
            if (_exposedName != null)
            {
                throw new Exception("Value has alread been exposed as: " + _exposedName);
            }

            if (name == null)
            {
                throw new Exception("Exposed name cannot be null!");
            }

            SimCapiValue simCapiValue = new SimCapiValue(name, SimCapiValueType.ARRAY_POINT, isReadonly, isWriteonly, false, new StringData(arrayToString()));
            bool         exposed      = Transporter.getInstance().getModel().exposeValue(this, simCapiValue);

            if (exposed == true)
            {
                _exposedName = name;
            }
        }
Exemplo n.º 12
0
        public void setData(string simId, string key, string value, SetDataRequestSuccessDelegate successDelegate)
        {
            bool success = ExternalCalls.setKeyPairSessionStorage(simId, key, value);

            SimCapiConsole.log("SimCapiLocalData set data: " + success.ToString());

            if (success == false)
            {
                return;
            }

            Message.SetDataResponse setDataResponse = new Message.SetDataResponse();
            setDataResponse.handshake    = Transporter.getInstance().getHandshake();
            setDataResponse.simId        = simId;
            setDataResponse.key          = key;
            setDataResponse.value        = value;
            setDataResponse.responseType = "success";

            if (success == true)
            {
                successDelegate(setDataResponse);
            }
        }
Exemplo n.º 13
0
 public SimCapiModel(Transporter transporter)
 {
     _transporter = transporter;
     _transporter.addChangeListener(handleValueChange);
     _valueMap = new Dictionary <string, SimCapiExposableValue>();
 }
Exemplo n.º 14
0
 public static void setSingleton(Transporter transporter)
 {
     _singleton = transporter;
 }