2015-04-26 01:46:51 +00:00
|
|
|
import std.stdio;
|
|
|
|
import ddbus.c_lib;
|
2015-04-29 01:00:48 +00:00
|
|
|
import ddbus.thin;
|
2015-05-02 00:36:06 +00:00
|
|
|
import ddbus.router;
|
|
|
|
import ddbus.bus;
|
2015-04-26 01:46:51 +00:00
|
|
|
|
2015-05-02 00:36:06 +00:00
|
|
|
void testCall(Connection conn) {
|
2015-04-29 01:00:48 +00:00
|
|
|
for(int i = 0; i < 50; i++) {
|
2015-05-01 20:59:40 +00:00
|
|
|
Message msg = Message("ca.thume.transience","/ca/thume/transience/screensurface",
|
2015-04-29 01:00:48 +00:00
|
|
|
"ca.thume.transience.screensurface","testDot");
|
|
|
|
conn.sendBlocking(msg);
|
|
|
|
}
|
2015-05-01 20:59:40 +00:00
|
|
|
Message msg2 = Message("ca.thume.transience","/ca/thume/transience/screensurface",
|
2015-04-29 01:00:48 +00:00
|
|
|
"ca.thume.transience.screensurface","testPing");
|
|
|
|
Message res = conn.sendWithReplyBlocking(msg2,3000);
|
|
|
|
int result = res.read!int();
|
|
|
|
writeln(result);
|
2015-05-02 00:36:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void testServe(Connection conn) {
|
|
|
|
auto router = new MessageRouter();
|
|
|
|
MessagePattern patt = MessagePattern("/root","ca.thume.test","test");
|
|
|
|
router.setHandler!(int,int)(patt,(int par) {
|
|
|
|
writeln("Called with ", par);
|
|
|
|
return par;
|
|
|
|
});
|
2015-05-02 00:53:39 +00:00
|
|
|
patt = MessagePattern("/signaler","ca.thume.test","signal",true);
|
|
|
|
router.setHandler!(void,int)(patt,(int par) {
|
|
|
|
writeln("Signalled with ", par);
|
|
|
|
});
|
2015-05-02 00:36:06 +00:00
|
|
|
registerRouter(conn, router);
|
|
|
|
writeln("Getting name...");
|
|
|
|
bool gotem = requestName(conn, "ca.thume.ddbus.test");
|
|
|
|
writeln("Got name: ",gotem);
|
|
|
|
simpleMainLoop(conn);
|
|
|
|
}
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
Connection conn = connectToBus();
|
|
|
|
testServe(conn);
|
2015-04-26 01:46:51 +00:00
|
|
|
writeln("It worked!");
|
|
|
|
}
|