Exemplo n.º 1
0
        /// <summary>
        /// Sends back to the originator
        /// </summary>
        /// <param name="sourceMessage">Original Message to reply to</param>
        /// <param name="TargetMessage">New message to be sent to originator</param>
        /// <param name="IncludeLocalNode">if true the message will be sent to localhost</param>
        /// <returns></returns>
        public bool SendToOriginator(TSM sourceMessage, TSM TargetMessage, bool IncludeLocalNode)
        {
            if (sourceMessage == null || TargetMessage == null)
            {
                return(false);
            }
            TargetMessage.SID = sourceMessage.SID;
            Guid tOrg = sourceMessage.GetOriginator();

            if (tOrg == Guid.Empty)
            {
                return(false);
            }
            TargetMessage.GRO = sourceMessage.ORG;
            Guid tOriginatorThing = sourceMessage.GetOriginatorThing();

            if (tOriginatorThing != Guid.Empty)
            {
                TargetMessage.OWN = tOriginatorThing.ToString();
            }
            if (IncludeLocalNode)
            {
                TheBaseAssets.LocalHostQSender.SendQueued(TheBaseAssets.MyScopeManager.AddScopeID("CDE_SYSTEMWIDE;" + FNI, null, ref sourceMessage.SID, true, false), TargetMessage, false, TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID, "CDE_SYSTEMWIDE", RS, null); //GRSI: rare
            }
            return(MyQSender.SendQueued(TheBaseAssets.MyScopeManager.AddScopeID("CDE_SYSTEMWIDE;" + tOrg, null, ref sourceMessage.SID, true, false), TargetMessage, false, tOrg, "CDE_SYSTEMWIDE", RS, null));                                                                  //GRSI: rare
        }
Exemplo n.º 2
0
        /// <summary>
        /// Unsubscribes from Custom topics on this ISB Connection. The Topics will be scoped with the scope used during connect
        /// </summary>
        /// <param name="pTopics">List of topics to subscribe to separated by ;</param>
        /// <param name="keepAlive">If true the QSender will not be destroyed if last subscription was removed</param>
        /// <returns></returns>
        public bool Unsubscribe(string pTopics, bool keepAlive)
        {
            string noMSG   = null;
            string strSubs = TheBaseAssets.MyScopeManager.AddScopeID(pTopics, RS, ref noMSG, false, true);     //GRSI: rare
            TSM    tTSM    = new TSM(eEngineName.ContentService, "CDE_UNSUBSCRIBE", strSubs);

            tTSM.SetNoDuplicates(true);
            tTSM.QDX = 2;
            MyQSender.Unsubscribe(strSubs, keepAlive);
            return(SendTSM(tTSM));
        }
Exemplo n.º 3
0
 /// <summary>
 /// Sends a message to the first node in the mesh. Is is the Node this ISB Connection is connected to
 /// </summary>
 /// <param name="TargetMessage"></param>
 /// <returns></returns>
 public bool SendToFirstNode(TSM TargetMessage)
 {
     if (TargetMessage == null)
     {
         return(false);
     }
     if (string.IsNullOrEmpty(TargetMessage.SID))
     {
         TargetMessage.SID = mSScope;
     }
     return(MyQSender.SendQueued(TheBaseAssets.MyScopeManager.AddScopeID("CDE_SYSTEMWIDE;" + MyQSender.MyTargetNodeChannel.TruDID, true, RS), TargetMessage, false, MyQSender.MyTargetNodeChannel.TruDID, "CDE_SYSTEMWIDE", RS, null));     //GRSI: rare
 }
Exemplo n.º 4
0
 /// <summary>
 /// Sends a TSM via the ISB Connection to a custom Topic specified in the first parameter
 /// </summary>
 /// <param name="pTopic">Subscription topic to send to</param>
 /// <param name="pSend">TSM to send</param>
 /// <returns></returns>
 public bool SendTSM(string pTopic, TSM pSend)
 {
     if (MyQSender == null || pSend == null)
     {
         return(false);
     }
     if (string.IsNullOrEmpty(pSend.SID))
     {
         pSend.SID = mSScope;
     }
     return(MyQSender.SendQueued(TheBaseAssets.MyScopeManager.AddScopeID(pTopic, RS, ref pSend.SID, false, true), pSend, false, Guid.Empty, pTopic, RS, null));     //GRSI: rare
 }
Exemplo n.º 5
0
 /// <summary>
 /// Sends a TSM to a specific node
 /// </summary>
 /// <param name="tOrg">Node to send to</param>
 /// <param name="TargetMessage">Message to be send</param>
 /// <param name="IncludeLocalNode">Not used! If tOrg is localhost the message will be sent to localhost</param>
 /// <returns></returns>
 public bool SendToNode(Guid tOrg, TSM TargetMessage, bool IncludeLocalNode)
 {
     if (tOrg == Guid.Empty || TargetMessage == null)
     {
         return(false);
     }
     if (string.IsNullOrEmpty(TargetMessage.SID))
     {
         TargetMessage.SID = mSScope;
     }
     if (IncludeLocalNode)
     {
         TheBaseAssets.LocalHostQSender.SendQueued(TheBaseAssets.MyScopeManager.AddScopeID("CDE_SYSTEMWIDE;" + FNI, true, RS), TargetMessage, false, TheBaseAssets.MyServiceHostInfo.MyDeviceInfo.DeviceID, "CDE_SYSTEMWIDE", RS, null); //GRSI: rare
     }
     return(MyQSender.SendQueued(TheBaseAssets.MyScopeManager.AddScopeID("CDE_SYSTEMWIDE;" + tOrg, true, RS), TargetMessage, false, tOrg, "CDE_SYSTEMWIDE", RS, null));                                                                  //GRSI: rare
 }
Exemplo n.º 6
0
 /// <summary>
 /// Sends a TSM with a custom topic with a possible target and Source Sender - in Par with ICDECommChannel
 /// </summary>
 /// <param name="tTSM"></param>
 /// <param name="pTopic"></param>
 /// <param name="pTarget"></param>
 /// <param name="pSender"></param>
 /// <returns></returns>
 public bool SendTSM(TSM tTSM, string pTopic = null, Guid?pTarget = null, Guid?pSender = null)
 {
     if (MyQSender == null || tTSM == null)
     {
         return(false);
     }
     if (!tTSM.ORG.Contains(":") && pSender != null)
     {
         tTSM.ORG += $":{TheCommonUtils.CGuid(pSender)}";
     }
     if (string.IsNullOrEmpty(tTSM.SID))
     {
         tTSM.SID = mSScope;
     }
     return(MyQSender.SendQueued(TheBaseAssets.MyScopeManager.AddScopeID(pTopic, RS, ref tTSM.SID, false, true), tTSM, false, TheCommonUtils.CGuid(pTarget), pTopic, RS, null));     //GRSI: rare
 }
Exemplo n.º 7
0
 /// <summary>
 /// Disposes the underlying QueuedSender. Don't use this if you have multiple ISBConnects to the same URL as they share the same QueuedSender
 /// </summary>
 /// <returns></returns>
 public bool Disconnect()
 {
     MyQSender?.DisposeSender(true);
     MyQSender = null;
     return(true);
 }