Esempio n. 1
0
 static void Main(string[] args)
 {
     /*
      * Make sure this path contains the umundoNativeCSharp.dll!
      */
     SetDllDirectory("C:\\Program Files\\uMundo\\lib");
     org.umundo.core.Node node = new org.umundo.core.Node();
     TypedPublisher pub = new TypedPublisher("s11ndemo");
     node.addPublisher(pub);
     TestTypedReceiver ttr = new TestTypedReceiver();
     TypedSubscriber sub = new TypedSubscriber("s11ndemo", ttr);
     node.addSubscriber(sub);
     // Currently not working in C#
     //Console.WriteLine("Waiting for subsrcibers...");
     //int subs = pub.waitForSubscribers(2);
     //Console.WriteLine(subs + " subscribers");
     AMessage msg = new AMessage();
     msg.a = 42;
     msg.b = 43;
     sub.RegisterType(msg.GetType().Name, msg.GetType());
     while (true)
     {
         Console.WriteLine("s: " + msg.a + ", " + msg.b);
         pub.SendObject(msg);
         System.Threading.Thread.Sleep(1000);
     }
 }
Esempio n. 2
0
        static void Main(string[] args)
        {
            /*
             * Make sure this path contains the umundoNativeCSharp.dll!
             */
            SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\umundo\\lib");
            org.umundo.core.Node node = new org.umundo.core.Node();
            Publisher pub = new Publisher("pingpong");
            PingReceiver recv = new PingReceiver();
            Subscriber sub = new Subscriber("pingpong", recv);
            node.addPublisher(pub);
            node.addSubscriber(sub);

            while (true)
            {
                Message msg = new Message();
                String data = "data";
                System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
                byte[] buffer = enc.GetBytes(data);
                msg.setData(buffer);
                msg.putMeta("foo", "bar");
                Console.Write("o");
                pub.send(msg);
                System.Threading.Thread.Sleep(1000);
            }
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            /*
             * Make sure this path contains the umundoNativeCSharp.dll!
             */
            SetDllDirectory("C:\\Program Files\\uMundo\\lib");
            org.umundo.core.Node node = new org.umundo.core.Node();
            TypedPublisher       pub  = new TypedPublisher("s11ndemo");

            node.addPublisher(pub);
            TestTypedReceiver ttr = new TestTypedReceiver();
            TypedSubscriber   sub = new TypedSubscriber("s11ndemo", ttr);

            node.addSubscriber(sub);
            // Currently not working in C#
            //Console.WriteLine("Waiting for subsrcibers...");
            //int subs = pub.waitForSubscribers(2);
            //Console.WriteLine(subs + " subscribers");
            AMessage msg = new AMessage();

            msg.a = 42;
            msg.b = 43;
            sub.RegisterType(msg.GetType().Name, msg.GetType());
            while (true)
            {
                Console.WriteLine("s: " + msg.a + ", " + msg.b);
                pub.SendObject(msg);
                System.Threading.Thread.Sleep(1000);
            }
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            /*
             * Make sure this path contains the umundoNativeCSharp.dll!
             */
            SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\umundo\\lib");
            org.umundo.core.Node node = new org.umundo.core.Node();
            Publisher            pub  = new Publisher("pingpong");
            PingReceiver         recv = new PingReceiver();
            Subscriber           sub  = new Subscriber("pingpong", recv);

            node.addPublisher(pub);
            node.addSubscriber(sub);

            while (true)
            {
                Message msg  = new Message();
                String  data = "data";
                System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
                byte[] buffer = enc.GetBytes(data);
                msg.setData(buffer);
                msg.putMeta("foo", "bar");
                Console.Write("o");
                pub.send(msg);
                System.Threading.Thread.Sleep(1000);
            }
        }
Esempio n. 5
0
        static void Main(string[] args)
        {
            /*
             * Make sure this path contains the umundoNativeCSharp.dll!
             */
            if (System.Environment.Is64BitProcess)
            {
                SetDllDirectory("C:\\Program Files (x86)\\uMundo\\share\\umundo\\bindings\\csharp64");
            }
            else
            {
                SetDllDirectory("C:\\Program Files (x86)\\uMundo\\share\\umundo\\bindings\\csharp");
            }

            org.umundo.core.Node node = new org.umundo.core.Node();

            org.umundo.core.Discovery disc = new org.umundo.core.Discovery(Discovery.DiscoveryType.MDNS);
            disc.add(node);

            TypedPublisher pub = new TypedPublisher("s11ndemo");

            node.addPublisher(pub);

            TestTypedReceiver ttr = new TestTypedReceiver();
            TypedSubscriber   sub = new TypedSubscriber("s11ndemo", ttr);

            node.addSubscriber(sub);

            Console.WriteLine("Waiting for subscribers...");
            int subs = pub.waitForSubscribers(1);

            Console.WriteLine(subs + " subscribers");

            AMessage msg = new AMessage();

            msg.a = 42;
            msg.b = 43;
            sub.RegisterType(msg.GetType().Name, msg.GetType());
            while (true)
            {
                Console.WriteLine("s: " + msg.a + ", " + msg.b);
                pub.SendObject(msg);
                System.Threading.Thread.Sleep(1000);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Handles the Click event of the Login control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            Globals.Username = txtName.Text;
            //If the user leaves the name empty show some error message
            if (String.IsNullOrWhiteSpace(Globals.Username))
            {
                MessageBox.Show("Please enter a valid username");
                return;
            }

            //Lock the text area and login button for further editing
            txtName.Enabled  = false;
            btnLogin.Enabled = false;

            #region Initialize uMundo
            org.umundo.core.Node      node = new org.umundo.core.Node();
            org.umundo.core.Discovery disc = new org.umundo.core.Discovery(Discovery.DiscoveryType.MDNS);
            disc.add(node);

            pub = new Publisher("coreGame");
            FlyHunterGreeter greeter = new FlyHunterGreeter(Globals.Username);
            greeter.UpdateScoreLocal += new FlyHunterGreeter.UpdateScoreLocalDelegate(UpdateScoreBoard);
            pub.setGreeter(greeter);
            FlyHunterReceiver recv = new FlyHunterReceiver();
            Globals.Players = new FlyHuntMessage();
            Globals.Players.Names.Add(Globals.Username);
            Globals.Players.Scores.Add("0");
            recv.UpdateScoreLocal += new FlyHunterReceiver.UpdateScoreLocalDelegate(UpdateScoreBoard);
            recv.RelocateFly      += new FlyHunterReceiver.RelocateFlyDelegate(RelocateFly);

            Globals.sub = new Subscriber("coreGame");
            Globals.sub.setReceiver(recv);
            node.addPublisher(pub);
            node.addSubscriber(Globals.sub);
            #endregion

            //Enable the main panel where fly appears
            panelMain.Enabled = true;
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            /*
             * Make sure this path contains the umundoNativeCSharp.dll!
             */
            if (System.Environment.Is64BitProcess)
            {
                SetDllDirectory("C:\\Program Files (x86)\\uMundo\\share\\umundo\\bindings\\csharp64");
            }
            else
            {
                SetDllDirectory("C:\\Program Files (x86)\\uMundo\\share\\umundo\\bindings\\csharp");
            }

            org.umundo.core.Node      node = new org.umundo.core.Node();
            org.umundo.core.Discovery disc = new org.umundo.core.Discovery(Discovery.DiscoveryType.MDNS);
            disc.add(node);

            Publisher    pub  = new Publisher("pingpong");
            PingReceiver recv = new PingReceiver();
            Subscriber   sub  = new Subscriber("pingpong", recv);

            node.addPublisher(pub);
            node.addSubscriber(sub);

            while (!Console.KeyAvailable)
            {
                Message msg  = new Message();
                String  data = "data";
                System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
                byte[] buffer = enc.GetBytes(data);
                msg.setData(buffer);
                msg.putMeta("foo", "bar");
                Console.Write("o");
                pub.send(msg);
                System.Threading.Thread.Sleep(1000);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Handles the Click event of the Login control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        private void btnLogin_Click(object sender, EventArgs e)
        {
            Globals.Username = txtName.Text;
            //If the user leaves the name empty show some error message
            if (String.IsNullOrWhiteSpace(Globals.Username))
            {
                MessageBox.Show("Please enter a valid username");
                return;
            }

            //Lock the text area and login button for further editing
            txtName.Enabled = false;
            btnLogin.Enabled = false;

            #region Initialize uMundo
            org.umundo.core.Node node = new org.umundo.core.Node();
            org.umundo.core.Discovery disc = new org.umundo.core.Discovery(Discovery.DiscoveryType.MDNS);
            disc.add(node);

            pub = new Publisher("coreGame");
            FlyHunterGreeter greeter = new FlyHunterGreeter(Globals.Username);
            greeter.UpdateScoreLocal += new FlyHunterGreeter.UpdateScoreLocalDelegate(UpdateScoreBoard);
            pub.setGreeter(greeter);
            FlyHunterReceiver recv = new FlyHunterReceiver();
            Globals.Players = new FlyHuntMessage();
            Globals.Players.Names.Add(Globals.Username);
            Globals.Players.Scores.Add("0");
            recv.UpdateScoreLocal += new FlyHunterReceiver.UpdateScoreLocalDelegate(UpdateScoreBoard);
            recv.RelocateFly += new FlyHunterReceiver.RelocateFlyDelegate(RelocateFly);

            Globals.sub = new Subscriber("coreGame");
            Globals.sub.setReceiver(recv);
            node.addPublisher(pub);
            node.addSubscriber(Globals.sub);
            #endregion

            //Enable the main panel where fly appears
            panelMain.Enabled = true;
        }