Example #1
0
        public TalkerSession(SessionTypeEnum sessionType, string busAddress)
        {
            topLevelTreeNode = null;
            bus = MQFactory.Instance.createMessagingBus();
            if (sessionType == SessionTypeEnum.Server)
            {
                talkerConnection = bus.create(new Uri(busAddress));
                ptpTalkerSession = talkerConnection.createPTPSession <T>("serverPTP", "ptpSimpleSession");
            }
            else if (sessionType == SessionTypeEnum.Client)
            {
                talkerConnection = bus.connect(new Uri(busAddress));
                ptpTalkerSession = talkerConnection.createPTPSession <T>("clientPTP", "ptpSimpleSession");
            }
            else
            {
                throw new Exception("Session Type must be either Server or Client");
            }
            this.sessionType = sessionType;

            talkerConnectionListener = new TalkerConnectionListener();
            talkerConnection.addListener(talkerConnectionListener);
            ptpTalkerSession.addListener(this);

            talkerConnection.start();
        }
Example #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;
     }
 }