static TimeSpan MaxTimeOut = new TimeSpan(1, 0, 0); // TODO Add to TheBaseAssets and make configurable? private static TSM PrepareRequestMessage(TheMessageAddress originator, TheMessageAddress target, string messageName, Guid correlationToken, string[] txtParameters, string PLS, byte[] PLB) { var parameterText = CreateParameterText(txtParameters); if (parameterText == null) { return(null); } TSM msg = new TSM(target.EngineName, String.Format("{0}:{1}:{2}", messageName, TheCommonUtils.cdeGuidToString(correlationToken), parameterText), PLS); if (PLB != null) { msg.PLB = PLB; } if (originator.ThingMID != Guid.Empty) { msg.SetOriginatorThing(originator.ThingMID); } if (target.ThingMID != Guid.Empty) { msg.OWN = TheCommonUtils.cdeGuidToString(target.ThingMID); } if (!string.IsNullOrEmpty(target.Route)) { msg.GRO = target.Route; } return(msg); }
public void IncomingMessage2EventTest() { var contentServiceThing = TheThingRegistry.GetBaseEngineAsThing(eEngineName.ContentService); var contentServiceEng = contentServiceThing.GetBaseEngine(); int numberOfMessages = 0; string txt = "CDE_GET_SERVICEINFO"; string payload = "CHNL"; TSM testMsg = new TSM(eEngineName.ContentService, txt, payload); contentServiceThing?.RegisterEvent(eEngineEvents.IncomingEngineMessage, (t, o) => { // Two messages should be received here - The first intercepts the CDE_GET_SERVICEINFO // The second intercepts the CDE_SERVICEINFO response (since originator Thing was set to ContentService) numberOfMessages++; }); testMsg.SetOriginatorThing(contentServiceThing); TheCommCore.PublishCentral(testMsg, true); TheCommonUtils.SleepOneEye(5000, 1000); Assert.AreEqual(numberOfMessages, 2); }