コード例 #1
0
ファイル: myMessages.cs プロジェクト: TRUMPF-IoT/cdePlugins
 public override cdeP SetProperty(string pName, object pValue)
 {
     if (MyBaseThing != null)
     {
         if (pName == "LastMessage")
         {
             SetLastMessage(TheScopeManager.GetTokenFromScrambledScopeID(), pValue.ToString());
         }
         return(MyBaseThing.SetProperty(pName, pValue));
     }
     return(null);
 }
コード例 #2
0
ファイル: myMessages.cs プロジェクト: TRUMPF-IoT/cdePlugins
        private string ReturnLastMessage()
        {
            string token  = TheScopeManager.GetTokenFromScrambledScopeID() + "@";
            string retStr = "";

            if (LastMsgs.ContainsKey(token))
            {
                retStr = LastMsgs[token];
                LastMsgs.RemoveNoCare(token);
            }
            return(retStr);
        }
コード例 #3
0
ファイル: myMessages.cs プロジェクト: TRUMPF-IoT/cdePlugins
        private void sinkProcessBand(TheRequestData pRequest)
        {
            if (pRequest == null)
            {
                return;
            }
            if (IsInterceptorProcessing)
            {
                return;
            }

            IsInterceptorProcessing = true;
            try
            {
                if (pRequest.RequestUri != null && !string.IsNullOrEmpty(pRequest.RequestUri.Query) && pRequest.RequestUri.Query.Length > 1)
                {
                    string[] QParts = pRequest.RequestUri.Query.Split('=');
                    if (QParts.Length > 1 && QParts[0].ToUpper() == "?SID")
                    {
                        lock (LastMsgs.MyLock)
                        {
                            string msg   = "ERR: No Message from target, yet";
                            string token = TheScopeManager.GetTokenFromScrambledScopeID(TheScopeManager.GetScrambledScopeIDFromEasyID(QParts[1])) + "@";
                            if (TheScopeManager.IsValidScopeID(TheScopeManager.GetScrambledScopeIDFromEasyID(QParts[1])))
                            {
                                msg             = ReturnLastMessage();
                                LastMsgs[token] = msg;
                            }
                            else
                            {
                                TSM tTSM = new TSM(MyBaseEngine.GetEngineName(), "GET_LAST_MSG");
                                tTSM.SID = TheScopeManager.GetScrambledScopeIDFromEasyID(QParts[1]);
                                TheCommCore.PublishToService(tTSM);
                                //TODO: Wait here until SET_LAST_MSG returns
                                if (LastMsgs.ContainsKey(token))
                                {
                                    msg = LastMsgs[token];
                                }
                            }
                            pRequest.ResponseBuffer   = TheCommonUtils.CUTF8String2Array(msg);
                            pRequest.StatusCode       = 200;
                            pRequest.ResponseMimeType = "text/html";
                            LastMsgs.RemoveNoCare(token);
                        }
                    }
                }
            }
            catch { }
            IsInterceptorProcessing = false;
        }
コード例 #4
0
ファイル: myMessages.cs プロジェクト: TRUMPF-IoT/cdePlugins
        /// <summary>
        /// Handles Messages sent from a host sub-engine to its clients
        /// </summary>
        public override void HandleMessage(ICDEThing sender, object pIncoming)
        {
            TheProcessMessage pMsg = pIncoming as TheProcessMessage;

            if (pMsg == null)
            {
                return;
            }
            string[] cmd = pMsg.Message.TXT.Split(':');
            switch (cmd[0])
            {
            case "CDE_INITIALIZED":
                MyBaseEngine.SetInitialized(pMsg.Message);
                break;

            case "CDE_INITIALIZE":
                if (MyBaseEngine.GetEngineState().IsService&& MyBaseEngine.GetEngineState().IsLiveEngine)
                {
                    if (!MyBaseEngine.GetEngineState().IsEngineReady)
                    {
                        MyBaseEngine.SetEngineReadiness(true, null);
                    }
                }
                MyBaseEngine.ReplyInitialized(pMsg.Message);
                break;

            case "REFFRESHME":
                InitServers();
                if (MyDash != null)
                {
                    MyDash.Reload(pMsg, false);
                }
                break;

            case "SET_LAST_MSG":
                SetLastMessage(TheScopeManager.GetTokenFromScrambledScopeID(pMsg.Message.SID), pMsg.Message.PLS);
                break;

            case "GET_LAST_MSG":
                TheCommCore.PublishToOriginator(pMsg.Message, new TSM(MyBaseEngine.GetEngineName(), "SET_LAST_MSG", ReturnLastMessage()));
                break;
            }
        }