Example #1
0
        /// <summary>
        /// Connect to a Custom URL via ISB Connect and a custom Scope
        /// </summary>
        /// <param name="pUrl">URL to connect to</param>
        /// <param name="pEasyScope">Easy ScopeID generator for the connection. If next parameter is true, this parameter will be interpreted as a scrambled ScopeID</param>
        /// <param name="pInitialSubscriptions">List of initial Subscriptions separated by ;</param>
        /// <param name="pIsScrambledID">If true, the EasyScopeID is a scrambled ScopeID</param>
        /// <returns></returns>
        public string Connect(string pUrl, string pEasyScope, string pInitialSubscriptions, bool pIsScrambledID)
        {
            if (string.IsNullOrEmpty(pUrl))
            {
                ERR = "no url set!";
                return(ERR);
            }
            if (string.IsNullOrEmpty(pEasyScope))
            {
                ERR = "No scope set - unscoped connection not allowed";
                return(ERR);
            }
            mURL      = pUrl;
            mInitSubs = pInitialSubscriptions;
            TheSessionState tSessionState = TheBaseAssets.MySession.CreateSession(null, Guid.Empty);

            if (!string.IsNullOrEmpty(pEasyScope))
            {
                if (pIsScrambledID)
                {
                    mSScope = tSessionState.SScopeID = pEasyScope;
                    RS      = TheBaseAssets.MyScopeManager.GetRealScopeID(tSessionState.SScopeID); //GRSI: rare
                }
                else
                {
                    RS      = TheBaseAssets.MyScopeManager.GetRealScopeIDFromEasyID(pEasyScope);
                    mSScope = tSessionState.SScopeID = TheBaseAssets.MyScopeManager.GetScrambledScopeID(RS, true);    //GRSI: rare
                }
            }
            MyQSender = new TheQueuedSender
            {
                MyISBlock = this
            };
            IS = TheBaseAssets.MyScopeManager.AddScopeID(pInitialSubscriptions, false, RS);
            if (MyQSender.StartSender(new TheChannelInfo(Guid.Empty, RS, cdeSenderType.CDE_CUSTOMISB, pUrl)
            {
                MySessionState = tSessionState
            }, null, false))
            {
                FNI        = MyQSender.MyTargetNodeChannel.cdeMID.ToString();
                SID        = tSessionState.SScopeID;
                OnThisNode = true;
            }
            else
            {
                ERR = "Qsender could not be created";
                TheBaseAssets.MySYSLOG.WriteToLog(299, TSM.L(eDEBUG_LEVELS.VERBOSE) ? null : new TSM("CoreComm", $"CreateCustomSender: QueuedSender could not be created for Target:{pUrl}", eMsgLevel.l7_HostDebugMessage));
                MyQSender = null;
            }
            return(ERR);
        }