2003-06-22 05:53:06 +00:00
|
|
|
using System;
|
2004-03-23 12:10:32 +00:00
|
|
|
using System.Threading;
|
|
|
|
|
using DBus;
|
|
|
|
|
using Gtk;
|
2003-06-22 05:53:06 +00:00
|
|
|
|
2004-03-23 12:10:32 +00:00
|
|
|
namespace DBus.Test
|
|
|
|
|
{
|
|
|
|
|
public class Test
|
|
|
|
|
{
|
|
|
|
|
public static Service service = null;
|
|
|
|
|
public static Connection connection = null;
|
2003-07-03 01:48:31 +00:00
|
|
|
|
2004-03-23 12:10:32 +00:00
|
|
|
public static int Main(string [] args)
|
|
|
|
|
{
|
|
|
|
|
TestServer testServer = new TestServer();
|
|
|
|
|
Thread serverThread = new Thread(new ThreadStart(testServer.StartServer));
|
|
|
|
|
serverThread.Start();
|
2003-06-22 22:59:31 +00:00
|
|
|
|
2004-03-23 12:10:32 +00:00
|
|
|
connection = Bus.GetSessionBus();
|
2004-08-29 18:14:30 +00:00
|
|
|
service = Service.Get(connection, "org.freedesktop.Test");
|
|
|
|
|
Thread.Sleep (1000);
|
2003-06-22 05:53:06 +00:00
|
|
|
|
2004-03-23 12:10:32 +00:00
|
|
|
TestObject testObject = (TestObject) service.GetObject(typeof(TestObject), "/org/freedesktop/Test/TestObject");
|
2004-08-29 18:14:30 +00:00
|
|
|
|
|
|
|
|
Console.WriteLine ("Got object [{0}]", testObject);
|
2003-07-03 01:48:31 +00:00
|
|
|
|
2004-03-23 12:10:32 +00:00
|
|
|
System.Console.WriteLine(testObject.Test1("Hello"));
|
2003-06-22 05:53:06 +00:00
|
|
|
|
2004-08-29 18:14:30 +00:00
|
|
|
Console.WriteLine ("Got object [{0}]", testObject);
|
|
|
|
|
|
2004-03-23 12:10:32 +00:00
|
|
|
//RunTests(testObject);
|
2003-07-03 01:48:31 +00:00
|
|
|
|
2004-03-23 12:10:32 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
2003-07-03 01:48:31 +00:00
|
|
|
|
2004-03-23 12:10:32 +00:00
|
|
|
public static void RunTests(TestObject testObject)
|
|
|
|
|
{
|
|
|
|
|
System.Console.WriteLine(testObject.Test1("Hello"));
|
|
|
|
|
}
|
2003-06-22 05:53:06 +00:00
|
|
|
}
|
2003-07-03 01:48:31 +00:00
|
|
|
|
2004-03-23 12:10:32 +00:00
|
|
|
public class TestServer
|
|
|
|
|
{
|
|
|
|
|
public Connection connection;
|
|
|
|
|
public Service service;
|
2003-07-03 01:48:31 +00:00
|
|
|
|
2004-03-23 12:10:32 +00:00
|
|
|
public TestServer()
|
|
|
|
|
{
|
|
|
|
|
Application.Init();
|
|
|
|
|
|
|
|
|
|
System.Console.WriteLine("Starting server...");
|
2003-07-03 01:48:31 +00:00
|
|
|
|
2004-03-23 12:10:32 +00:00
|
|
|
connection = Bus.GetSessionBus();
|
|
|
|
|
service = new Service(connection, "org.freedesktop.Test");
|
|
|
|
|
TestObject testObject = new TestObject();
|
|
|
|
|
service.RegisterObject(testObject, "/org/freedesktop/Test/TestObject");
|
2004-08-29 18:14:30 +00:00
|
|
|
|
|
|
|
|
System.Console.WriteLine("Foo!");
|
2004-03-23 12:10:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void StartServer()
|
|
|
|
|
{
|
|
|
|
|
Application.Run();
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-07-03 01:48:31 +00:00
|
|
|
|
2004-03-23 12:10:32 +00:00
|
|
|
[Interface("org.freedesktop.Test.TestObject")]
|
|
|
|
|
public class TestObject
|
|
|
|
|
{
|
|
|
|
|
[Method]
|
|
|
|
|
public virtual int Test1(string x)
|
|
|
|
|
{
|
|
|
|
|
System.Console.WriteLine("Called: " + x);
|
|
|
|
|
return 5;
|
|
|
|
|
}
|
|
|
|
|
}
|
2003-06-22 05:53:06 +00:00
|
|
|
}
|