blob: cb482cb0dc83559ede89eea7fd42fcfb5697e0d8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
using System;
using System.Threading;
using DBus;
using Gtk;
namespace DBus.Test
{
public class Test
{
public static Service service = null;
public static Connection connection = null;
public static int Main(string [] args)
{
TestServer testServer = new TestServer();
Thread serverThread = new Thread(new ThreadStart(testServer.StartServer));
serverThread.Start();
connection = Bus.GetSessionBus();
service = Service.Get(connection, "org.freedesktop.Test");
Thread.Sleep (1000);
TestObject testObject = (TestObject) service.GetObject(typeof(TestObject), "/org/freedesktop/Test/TestObject");
Console.WriteLine ("Got object [{0}]", testObject);
System.Console.WriteLine(testObject.Test1("Hello"));
Console.WriteLine ("Got object [{0}]", testObject);
//RunTests(testObject);
return 0;
}
public static void RunTests(TestObject testObject)
{
System.Console.WriteLine(testObject.Test1("Hello"));
}
}
public class TestServer
{
public Connection connection;
public Service service;
public TestServer()
{
Application.Init();
System.Console.WriteLine("Starting server...");
connection = Bus.GetSessionBus();
service = new Service(connection, "org.freedesktop.Test");
TestObject testObject = new TestObject();
service.RegisterObject(testObject, "/org/freedesktop/Test/TestObject");
System.Console.WriteLine("Foo!");
}
public void StartServer()
{
Application.Run();
}
}
[Interface("org.freedesktop.Test.TestObject")]
public class TestObject
{
[Method]
public virtual int Test1(string x)
{
System.Console.WriteLine("Called: " + x);
return 5;
}
}
}
|