Пример #1
0
        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;
        }