Ejemplo n.º 1
0
            public static string create_CHECK_START_RESPONSE(SimCapiHandshake handshake)
            {
                JObject message = new JObject();

                message.Add(new JProperty("type", SimCapiMessageType.CHECK_START_RESPONSE));
                message.Add("handshake", JObject.FromObject(handshake));
                return(message.ToString(Formatting.None));
            }
Ejemplo n.º 2
0
        public static string create_ALLOW_INTERNAL_ACCESS(SimCapiHandshake handshake)
        {
            JObject message = new JObject();

            message.Add(new JProperty("type", SimCapiMessageType.ALLOW_INTERNAL_ACCESS));
            message.Add("handshake", JObject.FromObject(handshake));
            return(message.ToString(Formatting.None));
        }
Ejemplo n.º 3
0
            public static string create_VALUE_CHANGE_REQUEST(SimCapiHandshake handshake)
            {
                JObject message = new JObject();

                message.Add(new JProperty("type", SimCapiMessageType.VALUE_CHANGE_REQUEST));
                message.Add("handshake", JObject.FromObject(handshake));
                return(message.ToString(Formatting.None));
            }
        public static SimCapiHandshake create(string requestToken, string authToken, string version)
        {
            SimCapiHandshake handshake = new SimCapiHandshake();

            handshake.requestToken = requestToken;
            handshake.authToken    = authToken;
            handshake.version      = version;
            return(handshake);
        }
Ejemplo n.º 5
0
        public static string create_CHECK_REQUEST(SimCapiHandshake handshake)
        {
            JObject message = new JObject();

            message.Add(new JProperty("type", SimCapiMessageType.CHECK_REQUEST));
            message.Add("handshake", JObject.FromObject(handshake));
            message.Add(new JProperty("values", new JObject()));
            message.Add(new JProperty("options", new JObject()));
            return(message.ToString(Formatting.None));
        }
Ejemplo n.º 6
0
            public static string create_INITIAL_SETUP_COMPLETE(SimCapiHandshake handshake)
            {
                JObject message = new JObject();

                message.Add(new JProperty("type", SimCapiMessageType.INITIAL_SETUP_COMPLETE));
                message.Add("handshake", JObject.FromObject(handshake));
                message.Add(new JProperty("values", new JObject()));
                message.Add(new JProperty("options", new JObject()));
                return(message.ToString(Formatting.None));
            }
        SimCapiHandshake createTestHandshake()
        {
            SimCapiHandshake handshake = new SimCapi.SimCapiHandshake();

            handshake.authToken         = uuid.generate();
            handshake.requestToken      = uuid.generate();
            handshake.version           = "<%= version %>";
            handshake.config            = new SimCapiConfig();
            handshake.config.context    = "AUTHOR";
            handshake.config.lessonId   = "86380";
            handshake.config.questionId = "q:1519302508090:124";
            return(handshake);
        }
Ejemplo n.º 8
0
            public static string create_REGISTERED_LOCAL_DATA_CHANGED(SimCapiHandshake handshake, string simId, string key, string value)
            {
                JObject message = new JObject();

                message.Add(new JProperty("type", SimCapiMessageType.REGISTERED_LOCAL_DATA_CHANGED));
                message.Add("handshake", JObject.FromObject(handshake));
                message.Add(new JProperty("values",
                                          new JObject(
                                              new JProperty("simId", simId),
                                              new JProperty("key", key),
                                              new JProperty("value", value)
                                              )
                                          ));
                return(message.ToString(Formatting.None));
            }
Ejemplo n.º 9
0
        public static string create_GET_DATA_REQUEST(SimCapiHandshake handshake, string key, string simId)
        {
            JObject message = new JObject();

            message.Add(new JProperty("type", SimCapiMessageType.GET_DATA_REQUEST));
            message.Add("handshake", JObject.FromObject(handshake));
            message.Add(new JProperty("values",
                                      new JObject(
                                          new JProperty("key", key),
                                          new JProperty("simId", simId)
                                          )
                                      ));

            return(message.ToString(Formatting.None));
        }
Ejemplo n.º 10
0
        public static string create_RESIZE_PARENT_CONTAINER_REQUEST(SimCapiHandshake handshake, int messageId, int width, int height)
        {
            JObject message = new JObject();

            message.Add(new JProperty("type", SimCapiMessageType.RESIZE_PARENT_CONTAINER_REQUEST));
            message.Add("handshake", JObject.FromObject(handshake));
            message.Add(new JProperty("values",
                                      new JObject(
                                          new JProperty("messageId", messageId),
                                          new JProperty("width", width),
                                          new JProperty("height", height)
                                          )
                                      ));

            return(message.ToString(Formatting.None));
        }
Ejemplo n.º 11
0
        public Transporter(MessagePipe messagePipe)
        {
            createMessageReciverObject();

            _messagePipe             = messagePipe;
            _messagePipe.transporter = this;

            _initialSetupComplete = false;
            _handshakeComplete    = false;
            _pendingOnReady       = false;
            _checkTriggered       = false;

            _resizeMessageId = 0;

            _handshake = SimCapiHandshake.create(uuid.generate(), null, "<%= version %>");


            _pendingMessagesForHandshake   = new List <string>();
            _pendingMessagesForValueChange = new List <string>();

            _outGoingMap = new Dictionary <string, SimCapiValue>();

            _changeListeners       = new HashSet <ChangeDelegateKey>();
            _configChangeListeners = new HashSet <ConfigChangeDelegateKey>();

            _checkCompleteListeners = new List <CheckCompleteKey>();
            _checkStartListeners    = new List <CheckStartKey>();

            _initialSetupCompleteListeners = new List <InitialSetupCompleteDelegate>();
            _handshakeListeners            = new List <HandshakeDelegate>();

            _setRequests = new Dictionary <string, Dictionary <string, SimCapiSetRequestCallback> >();
            _getRequests = new Dictionary <string, Dictionary <string, SimCapiGetRequestCallback> >();

            _resizeCallbacks = new Dictionary <int, ResizeSuccessDelegate>();

            _localDataChangedCallbacks = new Dictionary <string, Dictionary <string, LocalDataChangedKey> >();


            _simCapiModel     = new SimCapiModel(this);
            _simCapiLocalData = new SimCapiLocalData();

            // Value change delay
            _simCapiTimer = new SimCapiTimer(valueChangeDelay, sendValueChange);
        }
Ejemplo n.º 12
0
        public static string create_VALUE_CHANGE_force_arrays(SimCapiHandshake handshake, Dictionary <string, SimCapiValue> valueDictionary)
        {
            JObject values = new JObject();

            foreach (KeyValuePair <string, SimCapiValue> keyPair in valueDictionary)
            {
                values.Add(new JProperty(keyPair.Key, keyPair.Value.getJObjectForSerializationForceArrays()));
            }

            JObject message = new JObject();

            message.Add(new JProperty("type", SimCapiMessageType.VALUE_CHANGE));
            message.Add("handshake", JObject.FromObject(handshake));
            message.Add(new JProperty("values", values));
            message.Add(new JProperty("options", new JObject()));

            return(message.ToString(Formatting.None));
        }
Ejemplo n.º 13
0
            public static string create_SET_DATA_RESPONSE(SimCapiHandshake handshake,
                                                          string responseType,
                                                          string key,
                                                          string value,
                                                          string simId,
                                                          string error)
            {
                JObject message = new JObject();

                message.Add(new JProperty("type", SimCapiMessageType.SET_DATA_RESPONSE));
                message.Add("handshake", JObject.FromObject(handshake));
                message.Add(new JProperty("values",
                                          new JObject(
                                              new JProperty("responseType", responseType),
                                              new JProperty("key", key),
                                              new JProperty("value", value),
                                              new JProperty("simId", simId),
                                              new JProperty("error", error)
                                              )
                                          ));
                return(message.ToString(Formatting.None));
            }