コード例 #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
        void sendValueChange()
        {
            string jsonString = SimCapiJsonMaker.create_VALUE_CHANGE(_handshake, _outGoingMap);

            sendMessage(jsonString);

            foreach (string pendingMessage in _pendingMessagesForValueChange)
            {
                sendMessage(pendingMessage);
            }

            _pendingMessagesForValueChange.Clear();
        }
コード例 #3
0
        public LocalDataChangedKey registerLocalDataListener(string simId, string key, LocalDataChangedDelegate localDataChangedDelegate)
        {
            string jsonString = SimCapiJsonMaker.create_REGISTER_LOCAL_DATA_CHANGE_LISTENER(_handshake, key, simId);

            if (_localDataChangedCallbacks.ContainsKey(simId) == false)
            {
                _localDataChangedCallbacks[simId] = new Dictionary <string, LocalDataChangedKey>();
            }

            LocalDataChangedKey newKey = new LocalDataChangedKey(localDataChangedDelegate, simId, key);

            _localDataChangedCallbacks[simId][key] = newKey;

            sendMessage(jsonString);

            return(newKey);
        }
コード例 #4
0
        public void requestParentContainerResize(int width, int height, ResizeSuccessDelegate resizeSuccessDelegate)
        {
            int    messgeID      = ++_resizeMessageId;
            string resizeMessage = SimCapiJsonMaker.create_RESIZE_PARENT_CONTAINER_REQUEST(_handshake, messgeID, width, height);

            if (resizeSuccessDelegate != null)
            {
                _resizeCallbacks[messgeID] = resizeSuccessDelegate;
            }

            if (_handshake.authToken == null)
            {
                _pendingMessagesForHandshake.Add(resizeMessage);
            }
            else
            {
                sendMessage(resizeMessage);
            }
        }
コード例 #5
0
        public void triggerCheck(CheckCompleteDelegate checkCompleteDelegate)
        {
            if (_checkTriggered)
            {
                throw new System.Exception("You have already triggered a check event");
            }

            _checkTriggered = true;

            if (checkCompleteDelegate != null)
            {
                addCheckCompleteListener(checkCompleteDelegate, true);
            }

            string checkRequestMessage = SimCapiJsonMaker.create_CHECK_REQUEST(_handshake);

            _pendingMessagesForValueChange.Add(checkRequestMessage);

            notifyValueChange();
        }
コード例 #6
0
        public void notifyOnReady()
        {
            if (_handshake.authToken == null)
            {
                _pendingOnReady = true;

                // once everything is ready, we request a handshake from the viewer.
                requestHandshake();
            }
            else
            {
                string onReadyJsonString = SimCapiJsonMaker.create_ON_READY(_handshake);

                sendMessage(onReadyJsonString);
                _pendingOnReady = false;

                foreach (HandshakeDelegate handshakeDelegate in _handshakeListeners)
                {
                    handshakeDelegate(_handshake);
                }

                _handshakeComplete = true;
                _handshakeListeners.Clear();

                // send initial value snapshot
                notifyValueChange();
            }

            if (!ExternalCalls.isInIFrame())
            {
                Message.InitialSetupComplete initialSetupComplete = new Message.InitialSetupComplete();
                initialSetupComplete.handshake                = _handshake;
                initialSetupComplete.handshake.config         = new SimCapiConfig();
                initialSetupComplete.handshake.config.context = "VIEWER";

                handleInitialSetupComplete(initialSetupComplete);
            }
        }
コード例 #7
0
        /*
         * Send a HANDSHAKE_REQUEST message.
         */
        public void requestHandshake()
        {
            string jsonString = SimCapiJsonMaker.create_HANDSHAKE_REQUEST(_handshake);

            sendMessage(jsonString);
        }
コード例 #8
0
        public void requestInternalViewerAccess()
        {
            string jsonString = SimCapiJsonMaker.create_ALLOW_INTERNAL_ACCESS(_handshake);

            sendMessage(jsonString);
        }