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); } }
public void ReceiveObject(object o, Message msg) { AMessage rcvmsg = (AMessage)o; Console.WriteLine("r: " + rcvmsg.a + ", " + rcvmsg.b); }