Merge pull request #31 from kubo39/exampledir
Create example directory and separate client/server.
This commit is contained in:
commit
1a5df56a42
1
examples/.gitignore
vendored
Normal file
1
examples/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
dub.selections.json
|
1
examples/client/.gitignore
vendored
Normal file
1
examples/client/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
client
|
6
examples/client/dub.json
Normal file
6
examples/client/dub.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "client",
|
||||
"dependencies": {
|
||||
"ddbus": {"path": "../../"}
|
||||
}
|
||||
}
|
22
examples/client/source/app.d
Normal file
22
examples/client/source/app.d
Normal file
|
@ -0,0 +1,22 @@
|
|||
import core.time;
|
||||
import std.stdio;
|
||||
import ddbus;
|
||||
|
||||
void testCall(Connection conn) {
|
||||
for(int i = 0; i < 50; i++) {
|
||||
Message msg = Message("ca.thume.transience","/ca/thume/transience/screensurface",
|
||||
"ca.thume.transience.screensurface","testDot");
|
||||
conn.sendBlocking(msg);
|
||||
}
|
||||
Message msg2 = Message("ca.thume.transience","/ca/thume/transience/screensurface",
|
||||
"ca.thume.transience.screensurface","testPing");
|
||||
Message res = conn.sendWithReplyBlocking(msg2, 3.seconds);
|
||||
int result = res.read!int();
|
||||
writeln(result);
|
||||
}
|
||||
|
||||
void main() {
|
||||
Connection conn = connectToBus();
|
||||
testCall(conn);
|
||||
writeln("It worked!");
|
||||
}
|
1
examples/server/.gitignore
vendored
Normal file
1
examples/server/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
server
|
6
examples/server/dub.json
Normal file
6
examples/server/dub.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"name": "server",
|
||||
"dependencies": {
|
||||
"ddbus": {"path": "../../"}
|
||||
}
|
||||
}
|
|
@ -1,19 +1,6 @@
|
|||
import std.stdio;
|
||||
import ddbus;
|
||||
|
||||
void testCall(Connection conn) {
|
||||
for(int i = 0; i < 50; i++) {
|
||||
Message msg = Message("ca.thume.transience","/ca/thume/transience/screensurface",
|
||||
"ca.thume.transience.screensurface","testDot");
|
||||
conn.sendBlocking(msg);
|
||||
}
|
||||
Message msg2 = Message("ca.thume.transience","/ca/thume/transience/screensurface",
|
||||
"ca.thume.transience.screensurface","testPing");
|
||||
Message res = conn.sendWithReplyBlocking(msg2,3000);
|
||||
int result = res.read!int();
|
||||
writeln(result);
|
||||
}
|
||||
|
||||
void testServe(Connection conn) {
|
||||
auto router = new MessageRouter();
|
||||
MessagePattern patt = MessagePattern("/root","ca.thume.test","test");
|
||||
|
@ -35,5 +22,5 @@ void testServe(Connection conn) {
|
|||
void main() {
|
||||
Connection conn = connectToBus();
|
||||
testServe(conn);
|
||||
writeln("It worked!");
|
||||
writeln("It worked!");
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
module ddbus;
|
||||
|
||||
public import ddbus.thin;
|
||||
public import ddbus.router;
|
||||
public import ddbus.bus;
|
||||
|
|
Loading…
Reference in a new issue