コード例 #1
0
        private void OnReceaveMessage(object sender, ReceaveMessageEventArgs e)
        {
            TestAsyncComplexMessage testAsyncMessage = e.Message as TestAsyncComplexMessage;

            if (testAsyncMessage != null)
            {
                responceFromSlaveReceaved = true;
                ComplexSharedClass tmpAdditionalInfo = SlaveResponces.ConstructComplexResponceTemplate();
                bool isTheSameInfo = tmpAdditionalInfo.Equals(testAsyncMessage.AdditionalInfo);
                Assert.IsTrue(isTheSameInfo,
                              "Unexpected responce!");
            }
        }
コード例 #2
0
 public void DoAsyncComplexSlaveTest()
 {
     using (SlaveManager currentSlaveManager = new SlaveManager()) {
         IIPCGUID slaveReceaverGUID = new IPCReceaverGUID(currentSlaveManager.LaunchSlave());
         // wait for slave is launched and ininialized
         Thread.CurrentThread.Join(3000);
         using (BaseIPCDispatcher dispatcher = new BaseIPCDispatcher(slaveReceaverGUID)) {
             TestAsyncComplexMessage test = new TestAsyncComplexMessage(ReceaverHolder.GlobalApplicationReceaver.ReceaverID, null);
             Assert.IsTrue(dispatcher.Dispatch(test) == IPCDispatchResult.Success, "Unable to send message");
         }
         Thread.CurrentThread.Join(3000);
         Assert.IsTrue(responceFromSlaveReceaved, "Slave keep silence =(");
     }
 }
コード例 #3
0
        public static void OnReceaveMessage(object sender, ReceaveMessageEventArgs e)
        {
            Console.WriteLine(String.Format("Receaved message of type - {0} from sender with id = {1}", e.Message.MessageType, e.Message.SenderID.Value));
            TestAsyncMessage testAsyncMessage = e.Message as TestAsyncMessage;

            if (testAsyncMessage != null)
            {
                Console.WriteLine("Preparing responce to the master..." + testAsyncMessage.GetType().FullName);
                TestAsyncMessage test = new TestAsyncMessage(new IPCReceaverGUID());
                test.StrData = SlaveResponces.TestAsyncResponceString;
                Console.WriteLine("Forward responce to the master...");
                ForwardResponce(test, testAsyncMessage.SenderID);
                return;
            }

            TestAsyncComplexMessage testComplexAsyncMessage = e.Message as TestAsyncComplexMessage;

            if (testComplexAsyncMessage != null)
            {
                Console.WriteLine("Preparing responce to the master..." + testComplexAsyncMessage.GetType().FullName);
                TestAsyncComplexMessage test = new TestAsyncComplexMessage(new IPCReceaverGUID(), SlaveResponces.ConstructComplexResponceTemplate());
                Console.WriteLine("Forward responce to the master...");
                ForwardResponce(test, testComplexAsyncMessage.SenderID);
                return;
            }

            TestSyncMessage testSyncMessage = e.Message as TestSyncMessage;

            if (testSyncMessage != null)
            {
                Console.WriteLine("Emulation of some processing");
                Thread.CurrentThread.Join(SlaveResponces.SyncMessageSlaveDelay);
                testSyncMessage.StrOut = SlaveResponces.TestSyncResponceString;
                Console.WriteLine("Continue work....");
            }
        }