public static void Main() { BusG.Init (); Application.Init (); Button btn = new Button ("Click me"); btn.Clicked += OnClick; VBox vb = new VBox (false, 2); vb.PackStart (btn, false, true, 0); Window win = new Window ("D-Bus#"); win.SetDefaultSize (640, 480); win.Add (vb); win.Destroyed += delegate {Application.Quit ();}; win.ShowAll (); bus = Bus.Session; string bus_name = "org.ndesk.gtest"; ObjectPath path = new ObjectPath ("/org/ndesk/test"); if (bus.RequestName (bus_name) == RequestNameReply.PrimaryOwner) { //create a new instance of the object to be exported demo = new DemoObject (); bus.Register (path, demo); } else { //import a remote to a local proxy demo = bus.GetObject<DemoObject> (bus_name, path); } //run the main loop Application.Run (); }
IEnumerator StorageAsync() { Log.text = string.Empty; Debug.Log("Storage Tests"); var storage = StorageService.Instance; //Make sure you are logged in. yield return(StartCoroutine(SignIn())); // make objects List <DemoObject> _demoObjects = new List <DemoObject>(); for (int i = 0; i < 10; i++) { _demoObjects.Add(DemoObject.Create()); } // post 1 Debug.Log("Post 1..."); yield return(StartCoroutine(TaskAsync(storage.Update(_demoObjects.First())))); // post 9 Debug.Log("Post Set..."); yield return(StartCoroutine(TaskAsync(storage.UpdateSet(_demoObjects.ToArray())))); // get 1 Debug.Log("Get 1..."); yield return(StartCoroutine(TaskAsync(storage.Get <DemoObject>(_demoObjects.First().Id)))); // getset Debug.Log("Get Set..."); yield return(StartCoroutine(TaskAsync(storage.GetSet <DemoObject>(_demoObjects.Select(o => o.Id).ToArray())))); // query Debug.Log("Query Set..."); var query = new ODataQuery <DemoObject>().WhereGreaterThan("Id", 5).OrderBy("String").Take(5); yield return(StartCoroutine(TaskAsync(storage.Query(query)))); var first = _demoObjects.First(); // update prop Debug.Log("Update Prop..."); yield return(StartCoroutine(TaskAsync(storage.UpdateProperty(first.Id, "String", UnityEngine.Random.value.ToString())))); // delta Debug.Log("Update Delta..."); yield return(StartCoroutine(TaskAsync(storage.UpdateDelta(first.Id, "Number", 1)))); // delta Debug.Log("Sync..."); yield return(StartCoroutine(TaskAsync(storage.Sync(first)))); // delete Debug.Log("Delete..."); yield return(StartCoroutine(TaskAsync(storage.Delete(first)))); Debug.Log("Done"); }
public static void Main() { BusG.Init (); Application.Init (); Window win = new Window ("D-Bus#"); win.SetDefaultSize (640, 480); win.Destroyed += delegate {Application.Quit ();}; win.ShowAll (); bus = Bus.Session; sysBus = Bus.System.GetObject<IBus> ("org.freedesktop.DBus", new ObjectPath ("/org/freedesktop/DBus")); string bus_name = "org.ndesk.gtest"; ObjectPath path = new ObjectPath ("/org/ndesk/test"); if (bus.RequestName (bus_name) == RequestNameReply.PrimaryOwner) { //create a new instance of the object to be exported demo = new DemoObject (); sysBus.NameOwnerChanged += demo.FireChange; bus.Register (path, demo); } else { //import a remote to a local proxy demo = bus.GetObject<DemoObject> (bus_name, path); } //run the main loop Application.Run (); }
public void TestTracker(Action <PropertyChangeTracker> injection, bool shouldNotify) { var tracker = new PropertyChangeTracker(); var demoObject = DemoObject.Bake(); string detectedChangedTargetName = null; tracker.Add(demoObject, ((string obj) => { detectedChangedTargetName = obj; })); if (injection != null) { injection(tracker); } string changedTargetName = demoObject.Change(); if (shouldNotify) { Assert.That(changedTargetName, Is.EqualTo(detectedChangedTargetName)); } else { Assert.That(changedTargetName, Is.Not.EqualTo(detectedChangedTargetName)); } }
public static void Main() { BusG.Init(); Application.Init(); Window win = new Window("D-Bus#"); win.SetDefaultSize(640, 480); win.Destroyed += delegate { Application.Quit(); }; win.ShowAll(); bus = Bus.Session; sysBus = Bus.System.GetObject <IBus> ("org.freedesktop.DBus", new ObjectPath("/org/freedesktop/DBus")); string bus_name = "org.ndesk.gtest"; ObjectPath path = new ObjectPath("/org/ndesk/test"); if (bus.RequestName(bus_name) == RequestNameReply.PrimaryOwner) { //create a new instance of the object to be exported demo = new DemoObject(); sysBus.NameOwnerChanged += demo.FireChange; bus.Register(path, demo); } else { //import a remote to a local proxy demo = bus.GetObject <DemoObject> (bus_name, path); } //run the main loop Application.Run(); }
public DemoObject Post([FromBody] DemoObject body) { Storage.TryAdd(body.Number, body.Message); return(new DemoObject { Number = body.Number * 2, Message = $"{body.Message} {body.Message}" }); }
public void ToXml_can_convert_an_object_to_valid_xml() { var obj = new DemoObject {Name = "John Doe", Age = 99}; var xml = obj.ToXml().ToString(SaveOptions.DisableFormatting); Trace.WriteLine(xml); const string expected = "<DemoObject xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Name>John Doe</Name><Age>99</Age></DemoObject>"; Assert.AreEqual(expected, xml); }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); string name = "Demo Object with a FlagsAttribute Enumeration Property"; DemoObject theObject = ObjectSpace.FindObject <DemoObject>(CriteriaOperator.Parse("Name=?", name)); if (theObject == null) { theObject = ObjectSpace.CreateObject <DemoObject>(); theObject.Name = name; theObject.TestMe = TestFlagsAttributeEnum.AirTest | TestFlagsAttributeEnum.AirGround; } }
protected void PopupWindowControl_CustomizePopupWindowSize(object sender, CustomizePopupWindowSizeEventArgs e) { if (e.ShowViewSource.SourceView.ObjectTypeInfo.Name == "DemoObject") { PopupInfoDemoObject currentObjectInPopup = e.PopupFrame.View.CurrentObject as PopupInfoDemoObject; DemoObject currentParentObject = View.CurrentObject as DemoObject; if ((currentParentObject != null) && (currentObjectInPopup != null)) { e.Height = new Unit(currentParentObject.Height); e.Width = new Unit(currentParentObject.Width); e.Handled = true; } } }
private void OnEnable() { _blockDemoScenarios = new List <DemoScenario> { DemoScenarios.EditorBlockHorizontal, DemoScenarios.EditorBlockVertical, DemoScenarios.RoundedBox, DemoScenarios.EditorFrame, DemoScenarios.FoldableEditorFrame, DemoScenarios.SwitchGUIDepth, }; _demoObject = CreateInstance <DemoObject>(); _serializedObject = new SerializedObject(_demoObject); }
public void BusinessLogic_DoSomeActions_ActionsDone() { //arrange DemoObject testObject = new DemoObject(); var dataBase = new Mock <IDataBase>(); dataBase.Setup(x => x.GetObject()) .Returns(testObject); var businessLogic = new BusinessLogic(dataBase.Object); //act businessLogic.DoSomeActions(); //assert Assert.IsTrue(testObject.NeedUpdate); dataBase.Verify(x => x.GetObject(), Times.Once); dataBase.Verify(x => x.SaveObject(testObject), Times.Once); }
public override void UpdateDatabaseAfterUpdateSchema() { base.UpdateDatabaseAfterUpdateSchema(); for (byte i = 0; i <= 10; i++) { var width = i * 40 + 600; var height = i * 20 + 400; DemoObject obj = ObjectSpace.FindObject <DemoObject>( CriteriaOperator.Parse( string.Format("Width = '{0}' and Height = '{1}'", width, height))); if (obj == null) { obj = ObjectSpace.CreateObject <DemoObject>(); obj.Width = width; obj.Height = height; } } ObjectSpace.CommitChanges(); }
public static void Handle(Connection conn) { string myNameReq = "org.ndesk.test"; ObjectPath myOpath = new ObjectPath("/org/ndesk/test"); DemoObject demo = new DemoObject(); conn.Register(myNameReq, myOpath, demo); //TODO: handle lost connections etc. properly instead of stupido try/catch try { while (true) { conn.Iterate(); } } catch (Exception e) { //Console.Error.WriteLine (e); } conn.Unregister(myNameReq, myOpath); }
public static void Main() { BusG.Init(); Application.Init(); Button btn = new Button("Click me"); btn.Clicked += OnClick; VBox vb = new VBox(false, 2); vb.PackStart(btn, false, true, 0); Window win = new Window("D-Bus#"); win.SetDefaultSize(640, 480); win.Add(vb); win.Destroyed += delegate { Application.Quit(); }; win.ShowAll(); bus = Bus.Session; string bus_name = "org.ndesk.gtest"; ObjectPath path = new ObjectPath("/org/ndesk/test"); if (bus.RequestName(bus_name) == RequestNameReply.PrimaryOwner) { //create a new instance of the object to be exported demo = new DemoObject(); bus.Register(path, demo); } else { //import a remote to a local proxy demo = bus.GetObject <DemoObject> (bus_name, path); } //run the main loop Application.Run(); }
protected override void Seed(SiteContext context) { if (System.Diagnostics.Debugger.IsAttached == false) { System.Diagnostics.Debugger.Launch(); } var demo = new DemoObject { DemoText = @"<p>This demonstration is about MVC itself and how it can be sed as a powerful way to quickly get ideas from conception to reality" }; var demoInfo = new DemoSummary { DemoTitle = "Basic MVC Skills", DemoDescription = "A post to show basic familarity with MVC", Demo = demo }; context.DemoSummaries.Add(demoInfo); context.SaveChanges(); }
//TODO: complete this test daemon/server example, and a client //TODO: maybe generalise it and integrate it into the core public static void Main(string[] args) { bool isServer; if (args.Length == 1 && args[0] == "server") { isServer = true; } else if (args.Length == 1 && args[0] == "client") { isServer = false; } else { Console.Error.WriteLine("Usage: test-server [server|client]"); return; } //string addr = "unix:abstract=/tmp/dbus-ABCDEFGHIJ"; string addr = "unix:path=/tmp/dbus-ABCDEFGHIJ"; Connection conn; ObjectPath myOpath = new ObjectPath("/org/ndesk/test"); string myNameReq = "org.ndesk.test"; if (!isServer) { conn = new Connection(Transport.Create(AddressEntry.Parse(addr))); DemoObject demo = conn.GetObject <DemoObject> (myNameReq, myOpath); demo.GiveNoReply(); //float ret = demo.Hello ("hi from test client", 21); float ret = 200; while (ret > 5) { ret = demo.Hello("hi from test client", (int)ret); Console.WriteLine("Returned float: " + ret); System.Threading.Thread.Sleep(1000); } } else { string path; bool abstr; AddressEntry entry = AddressEntry.Parse(addr); path = entry.Properties["path"]; UnixSocket server = new UnixSocket(); byte[] p = Encoding.Default.GetBytes(path); byte[] sa = new byte[2 + p.Length + 1]; //we use BitConverter to stay endian-safe byte[] afData = BitConverter.GetBytes(UnixSocket.AF_UNIX); sa[0] = afData[0]; sa[1] = afData[1]; for (int i = 0; i != p.Length; i++) { sa[2 + i] = p[i]; } sa[2 + p.Length] = 0; //null suffix for domain socket addresses, see unix(7) server.Bind(sa); //server.Listen (1); server.Listen(5); while (true) { Console.WriteLine("Waiting for client on " + addr); UnixSocket client = server.Accept(); Console.WriteLine("Client accepted"); //client.Blocking = true; //PeerCred pc = new PeerCred (client); //Console.WriteLine ("PeerCred: pid={0}, uid={1}, gid={2}", pc.ProcessID, pc.UserID, pc.GroupID); UnixNativeTransport transport = new UnixNativeTransport(); transport.Stream = new UnixStream(client.Handle); conn = new Connection(transport); //ConnectionHandler.Handle (conn); //in reality a thread per connection is of course too expensive ConnectionHandler hnd = new ConnectionHandler(conn); new Thread(new ThreadStart(hnd.Handle)).Start(); Console.WriteLine(); } } }
public JsonResult Post([FromBody] DemoObject value) { return(Json(value)); }
public static void Handle (Connection conn) { string myNameReq = "org.ndesk.test"; ObjectPath myOpath = new ObjectPath ("/org/ndesk/test"); DemoObject demo = new DemoObject (); conn.Register (myNameReq, myOpath, demo); //TODO: handle lost connections etc. properly instead of stupido try/catch try { while (true) conn.Iterate (); } catch (Exception e) { //Console.Error.WriteLine (e); } conn.Unregister (myNameReq, myOpath); }
public static void Main () { Bus bus = Bus.Session; string bus_name = "org.ndesk.test"; ObjectPath path = new ObjectPath ("/org/ndesk/test"); DemoObject demo; if (bus.RequestName (bus_name) == RequestNameReply.PrimaryOwner) { //create a new instance of the object to be exported demo = new DemoObject (); bus.Register (path, demo); //run the main loop while (true) bus.Iterate (); } else { //import a remote to a local proxy demo = bus.GetObject<DemoObject> (bus_name, path); } demo.Say ("Hello world!"); demo.Say ("Sibérie"); demo.Say (21); demo.SayByteArray (new byte[] {0, 2, 1}, "test string"); demo.SayByteEnumArray (new BEnum[] {BEnum.Zero, BEnum.Two, BEnum.One}, "test string two"); Console.WriteLine (demo.EchoCaps ("foo bar")); Console.WriteLine (demo.GetEnum ()); demo.CheckEnum (DemoEnum.Bar); demo.CheckEnum (demo.GetEnum ()); Console.WriteLine (); long someLong = demo.GetSomeLong (); Console.WriteLine ("someLong: " + someLong); Console.WriteLine (); ulong someULong = demo.GetSomeULong (); Console.WriteLine ("someULong: " + someULong); /* Console.WriteLine (); string outVal; demo.ReturnOut (out outVal); Console.WriteLine ("outVal: " + outVal); */ Console.WriteLine (); string[] texts = {"one", "two", "three"}; texts = demo.EchoCapsArr (texts); foreach (string text in texts) Console.WriteLine (text); Console.WriteLine (); string[][] arrarr = demo.ArrArr (); Console.WriteLine (arrarr[1][0]); Console.WriteLine (); int[] vals = demo.TextToInts ("1 2 3"); foreach (int val in vals) Console.WriteLine (val); Console.WriteLine (); MyTuple fooTuple = demo.GetTuple (); Console.WriteLine ("A: " + fooTuple.A); Console.WriteLine ("B: " + fooTuple.B); Console.WriteLine (); //KeyValuePair<string,string>[] kvps = demo.GetDict (); IDictionary<string,string> dict = demo.GetDict (); foreach (KeyValuePair<string,string> kvp in dict) Console.WriteLine (kvp.Key + ": " + kvp.Value); Console.WriteLine (); demo.SomeEvent += delegate (string arg1, object arg2, double arg3, MyTuple mt) {Console.WriteLine ("SomeEvent handler: " + arg1 + ", " + arg2 + ", " + arg3 + ", " + mt.A + ", " + mt.B);}; demo.SomeEvent += delegate (string arg1, object arg2, double arg3, MyTuple mt) {Console.WriteLine ("SomeEvent handler two: " + arg1 + ", " + arg2 + ", " + arg3 + ", " + mt.A + ", " + mt.B);}; demo.FireOffSomeEvent (); //handle the raised signal //bus.Iterate (); Console.WriteLine (); demo.SomeEvent += HandleSomeEventA; demo.FireOffSomeEvent (); //handle the raised signal //bus.Iterate (); Console.WriteLine (); demo.SomeEvent -= HandleSomeEventA; demo.FireOffSomeEvent (); //handle the raised signal //bus.Iterate (); Console.WriteLine (); { object tmp = demo.GetArrayOfInts (); int[] arr = (int[])tmp; Console.WriteLine ("Array of ints as variant: " + arr[0] + " " + arr[1]); } Console.WriteLine (); { demo.UseSomeVariant ("hello"); demo.UseSomeVariant (21); } Console.WriteLine (); { Console.WriteLine ("get SomeProp: " + demo.SomeProp); demo.SomeProp = 4; } }
public static void Main(string[] args) { bool isServer; int port; string hostname = "127.0.0.1"; //IPAddress ipaddr = IPAddress.Parse ("127.0.0.1"); if (args.Length == 2 && args[0] == "server") { isServer = true; port = Int32.Parse(args[1]); } else if (args.Length == 3 && args[0] == "client") { isServer = false; hostname = args[1]; port = Int32.Parse(args[2]); } else { Console.Error.WriteLine("Usage: test-server-tcp [server PORT|client HOSTNAME PORT]"); return; } Connection conn; ObjectPath myOpath = new ObjectPath("/org/ndesk/test"); string myNameReq = "org.ndesk.test"; if (!isServer) { SocketTransport transport = new SocketTransport(); transport.Open(hostname, port); conn = new Connection(transport); DemoObject demo = conn.GetObject <DemoObject> (myNameReq, myOpath); demo.GiveNoReply(); //float ret = demo.Hello ("hi from test client", 21); float ret = 200; while (ret > 5) { ret = demo.Hello("hi from test client", (int)ret); Console.WriteLine("Returned float: " + ret); System.Threading.Thread.Sleep(1000); } } else { TcpListener server = new TcpListener(IPAddress.Any, port); server.Start(); while (true) { Console.WriteLine("Waiting for client on " + port); TcpClient client = server.AcceptTcpClient(); Console.WriteLine("Client accepted"); //TODO: use the right abstraction here, probably using the Server class SocketTransport transport = new SocketTransport(); transport.Stream = client.GetStream(); conn = new Connection(transport); //conn.SocketHandle = (long)clientSocket.Handle; //ConnectionHandler.Handle (conn); //in reality a thread per connection is of course too expensive ConnectionHandler hnd = new ConnectionHandler(conn); new Thread(new ThreadStart(hnd.Handle)).Start(); Console.WriteLine(); } } }
public static void Main () { Bus bus = Bus.Session; string bus_name = "org.ndesk.testexceptions"; ObjectPath path = new ObjectPath ("/org/ndesk/testexceptions"); DemoObject demo; if (bus.RequestName (bus_name) == RequestNameReply.PrimaryOwner) { //create a new instance of the object to be exported demo = new DemoObject (); bus.Register (path, demo); //run the main loop while (true) bus.Iterate (); } else { //import a remote to a local proxy demo = bus.GetObject<DemoObject> (bus_name, path); } Console.WriteLine (); //org.freedesktop.DBus.Error.InvalidArgs: Requested bus name "" is not valid try { bus.RequestName (""); } catch (Exception e) { Console.WriteLine (e); } //TODO: make this work as expected (what is expected?) Console.WriteLine (); try { demo.ThrowSomeException (); } catch (Exception e) { Console.WriteLine (e); } Console.WriteLine (); try { demo.ThrowSomeExceptionNoRet (); } catch (Exception e) { Console.WriteLine (e); } //handle the thrown exception //conn.Iterate (); Console.WriteLine (); try { demo.HandleVariant (null); } catch (Exception e) { Console.WriteLine (e); } Console.WriteLine (); try { demo.HandleString (null); } catch (Exception e) { Console.WriteLine (e); } Console.WriteLine (); try { demo.HandleArray (null); } catch (Exception e) { Console.WriteLine (e); } }
public static void Main() { Bus bus = Bus.Session; string bus_name = "org.ndesk.testexceptions"; ObjectPath path = new ObjectPath("/org/ndesk/testexceptions"); DemoObject demo; if (bus.RequestName(bus_name) == RequestNameReply.PrimaryOwner) { //create a new instance of the object to be exported demo = new DemoObject(); bus.Register(path, demo); //run the main loop while (true) { bus.Iterate(); } } else { //import a remote to a local proxy demo = bus.GetObject <DemoObject> (bus_name, path); } Console.WriteLine(); //org.freedesktop.DBus.Error.InvalidArgs: Requested bus name "" is not valid try { bus.RequestName(""); } catch (Exception e) { Console.WriteLine(e); } //TODO: make this work as expected (what is expected?) Console.WriteLine(); try { demo.ThrowSomeException(); } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine(); try { demo.ThrowSomeExceptionNoRet(); } catch (Exception e) { Console.WriteLine(e); } //handle the thrown exception //conn.Iterate (); Console.WriteLine(); try { demo.HandleVariant(null); } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine(); try { demo.HandleString(null); } catch (Exception e) { Console.WriteLine(e); } Console.WriteLine(); try { demo.HandleArray(null); } catch (Exception e) { Console.WriteLine(e); } }
public static void Main() { Bus bus = Bus.Session; string bus_name = "org.ndesk.test"; ObjectPath path = new ObjectPath("/org/ndesk/test"); DemoObject demo; if (bus.RequestName(bus_name) == RequestNameReply.PrimaryOwner) { //create a new instance of the object to be exported demo = new DemoObject(); bus.Register(path, demo); //run the main loop while (true) { bus.Iterate(); } } else { //import a remote to a local proxy demo = bus.GetObject <DemoObject> (bus_name, path); } demo.Say("Hello world!"); demo.Say("Sibérie"); demo.Say(21); demo.SayByteArray(new byte[] { 0, 2, 1 }, "test string"); demo.SayByteEnumArray(new BEnum[] { BEnum.Zero, BEnum.Two, BEnum.One }, "test string two"); Console.WriteLine(demo.EchoCaps("foo bar")); Console.WriteLine(demo.GetEnum()); demo.CheckEnum(DemoEnum.Bar); demo.CheckEnum(demo.GetEnum()); Console.WriteLine(); long someLong = demo.GetSomeLong(); Console.WriteLine("someLong: " + someLong); Console.WriteLine(); ulong someULong = demo.GetSomeULong(); Console.WriteLine("someULong: " + someULong); /* * Console.WriteLine (); * string outVal; * demo.ReturnOut (out outVal); * Console.WriteLine ("outVal: " + outVal); */ Console.WriteLine(); string[] texts = { "one", "two", "three" }; texts = demo.EchoCapsArr(texts); foreach (string text in texts) { Console.WriteLine(text); } Console.WriteLine(); string[][] arrarr = demo.ArrArr(); Console.WriteLine(arrarr[1][0]); Console.WriteLine(); int[] vals = demo.TextToInts("1 2 3"); foreach (int val in vals) { Console.WriteLine(val); } Console.WriteLine(); MyTuple fooTuple = demo.GetTuple(); Console.WriteLine("A: " + fooTuple.A); Console.WriteLine("B: " + fooTuple.B); Console.WriteLine(); //KeyValuePair<string,string>[] kvps = demo.GetDict (); IDictionary <string, string> dict = demo.GetDict(); foreach (KeyValuePair <string, string> kvp in dict) { Console.WriteLine(kvp.Key + ": " + kvp.Value); } Console.WriteLine(); demo.SomeEvent += delegate(string arg1, object arg2, double arg3, MyTuple mt) { Console.WriteLine("SomeEvent handler: " + arg1 + ", " + arg2 + ", " + arg3 + ", " + mt.A + ", " + mt.B); }; demo.SomeEvent += delegate(string arg1, object arg2, double arg3, MyTuple mt) { Console.WriteLine("SomeEvent handler two: " + arg1 + ", " + arg2 + ", " + arg3 + ", " + mt.A + ", " + mt.B); }; demo.FireOffSomeEvent(); //handle the raised signal //bus.Iterate (); Console.WriteLine(); demo.SomeEvent += HandleSomeEventA; demo.FireOffSomeEvent(); //handle the raised signal //bus.Iterate (); Console.WriteLine(); demo.SomeEvent -= HandleSomeEventA; demo.FireOffSomeEvent(); //handle the raised signal //bus.Iterate (); Console.WriteLine(); { object tmp = demo.GetArrayOfInts(); int[] arr = (int[])tmp; Console.WriteLine("Array of ints as variant: " + arr[0] + " " + arr[1]); } Console.WriteLine(); { demo.UseSomeVariant("hello"); demo.UseSomeVariant(21); } Console.WriteLine(); { Console.WriteLine("get SomeProp: " + demo.SomeProp); demo.SomeProp = 4; } }
//TODO: complete this test daemon/server example, and a client //TODO: maybe generalise it and integrate it into the core public static void Main(string[] args) { bool isServer; if (args.Length == 1 && args[0] == "server") { isServer = true; } else if (args.Length == 1 && args[0] == "client") { isServer = false; } else { Console.Error.WriteLine("Usage: test-server [server|client]"); return; } string addr = "unix:abstract=/tmp/dbus-ABCDEFGHIJ"; Connection conn; ObjectPath myOpath = new ObjectPath("/org/ndesk/test"); string myNameReq = "org.ndesk.test"; if (!isServer) { conn = new Connection(addr); DemoObject demo = conn.GetObject <DemoObject> (myNameReq, myOpath); demo.GiveNoReply(); //float ret = demo.Hello ("hi from test client", 21); float ret = 200; while (ret > 5) { ret = demo.Hello("hi from test client", (int)ret); Console.WriteLine("Returned float: " + ret); System.Threading.Thread.Sleep(1000); } } else { string path; bool abstr; Address.Parse(addr, out path, out abstr); AbstractUnixEndPoint ep = new AbstractUnixEndPoint(path); Socket server = new Socket(AddressFamily.Unix, SocketType.Stream, 0); server.Bind(ep); //server.Listen (1); server.Listen(5); while (true) { Console.WriteLine("Waiting for client on " + addr); Socket client = server.Accept(); Console.WriteLine("Client accepted"); client.Blocking = true; PeerCred pc = new PeerCred(client); Console.WriteLine("PeerCred: pid={0}, uid={1}, gid={2}", pc.ProcessID, pc.UserID, pc.GroupID); conn = new Connection(null); conn.ns = new NetworkStream(client); conn.SocketHandle = (long)client.Handle; //ConnectionHandler.Handle (conn); //in reality a thread per connection is of course too expensive ConnectionHandler hnd = new ConnectionHandler(conn); new Thread(new ThreadStart(hnd.Handle)).Start(); Console.WriteLine(); } } }