Example #1
0
        public static void Main(string[] args)
        {
            r = new Random();
            MEETNode mn = new MEETNode("TestContainer");

            pcq  = new MEETPCQueue(5);
            tqm1 = new TestQModule("tqm1", mn, pcq);
            tm2  = new TestModule("tm2", mn);
            mc   = new MEETClock("mc", mn);
            mc.Start();
            tqm1.Start();
            Thread.Sleep(500);
            tm2.Start();
            Thread.Sleep(2000);
            tm2.Stop();
            Thread.Sleep(2000);
            tqm1.Stop();
            Thread.Sleep(1000);
            mn.Shutdown();

            Debug.WriteLine("dumping Log:");
            IList log = mn.Log;

            Debug.WriteLine("dumping Log:");
            foreach (string s in log)
            {
                Debug.WriteLine(s);
            }
        }
Example #2
0
 public TestQModule(string myName, MEETContainer theContainer, MEETPCQueue theQ) :
     base(myName, theContainer, theQ)
 {
 }
        private void mnuConnect_Click(object sender, EventArgs e)
        {
            Connect _connect = new Connect(m_node);

            _connect.ShowDialog();
            if (_connect.DialogResult == DialogResult.Cancel)
            {
                m_log.Add("User selected cancel");
                _connect.Dispose();
                return;
            }

            MEETIPEndPoint ipepLoc = _connect.MipLocalEndPoint;
            MEETIFace      iface   = (MEETIFace)m_node.IFaces[ipepLoc.Address];

            if (iface == null)
            {
                iface = new MEETIFace(ipepLoc.Address.ToString(), ipepLoc.Address, m_node);
                m_node.IFaces[ipepLoc.Address] = iface;
            }
            MEETIPEndPoint ipepRem = _connect.MipRemoteEndPoint;

            // create connection
            MEETPCQueue        inQ  = new MEETPCQueue();
            MEETPCQueue        outQ = new MEETPCQueue();
            MEETSockConnection conn = new MEETSockConnection(iface, ipepLoc, ipepRem, inQ, outQ, false);

            // see if it failed
            if (conn.Sock == null)
            {
                MessageBox.Show("failed to connect to " + ipepRem + ":" +
                                conn.ErrorSrc.Message,
                                "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation,
                                MessageBoxDefaultButton.Button1);
                conn.Close();
                return;
            }

            // check to see if already listed
            if (iface.htConns[conn] != null)
            {
                MessageBox.Show("Already connected to " + ipepRem,
                                "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation,
                                MessageBoxDefaultButton.Button1);
                conn.Close();
                return;
            }

            // add connection to interface
            // note stupid syntax; brain dead Collection class only sorts Dict objects...
            iface.htConns[conn] = conn;

            _connect.Dispose();

            MEETInDespatch indesp = new MEETInDespatch("udp" + conn.IpepRemote, iface, inQ);

            indesp.Start();
            conn.StartBidirectional();
            m_log.Add("\tdone.");
        }