Esempio n. 1
0
        public void testPTPSession()
        {
            IMessagingBus        bus = MQFactory.Instance.createMessagingBus();
            IMQConnection        serverConnection = null;
            IMQConnection        clientConnection = null;
            IPTPSession <String> ptpClientSession = null;
            IPTPSession <String> ptpServerSession = null;

            try {
                serverConnection = bus.create(new Uri("bnmq://127.0.0.1:3333"));
                ptpServerSession = serverConnection.createPTPSession <String>("serverPTP", "ptpSimpleSession");
                ptpServerSession.addListener(new TestPTPSessionListener());
                serverConnection.start();

                clientConnection = bus.connect(new Uri("bnmq://127.0.0.1:3333"));
                ptpClientSession = clientConnection.createPTPSession <String>("clientPTP", "ptpSimpleSession");
                ptpClientSession.addListener(new TestPTPSessionListener());
                clientConnection.start();

                string result = ptpClientSession.call("Hello from PTP Client", 20);
                Assert.Equals(result, "Hello from RPC/PTP");
                ptpClientSession.callAsync("Hello from Server 2", new TestRPCAsyncCallBack(), 20);

                Thread.Sleep(2000);
            }
            catch (Exception e) {
                Console.WriteLine(e.ToString());
                throw e;
            }
            finally {
                if (ptpClientSession != null)
                {
                    ptpClientSession.close();
                }
                if (ptpServerSession != null)
                {
                    ptpServerSession.close();
                }

                if (clientConnection != null)
                {
                    clientConnection.close();
                }
                if (serverConnection != null)
                {
                    serverConnection.close();
                }
                if (bus != null)
                {
                    bus.close();
                }
            }
        }
Esempio n. 2
0
 public void Close()
 {
     if (bus != null)
     {
         bus.close();
         bus = null;
     }
     if (talkerConnection != null)
     {
         talkerConnection.close(); // not sure why this locks up
         talkerConnection = null;
     }
     if (talkerConnectionListener != null)
     {
         talkerConnectionListener.Close();
         talkerConnectionListener = null;
     }
     if (ptpTalkerSession != null)
     {
         ptpTalkerSession.close();
         ptpTalkerSession = null;
     }
 }