Create example directory and separate client/server.

This commit is contained in:
Hiroki Noda 2017-12-03 21:29:59 +09:00
parent ce7716463d
commit 9007eacdf3
8 changed files with 46 additions and 13 deletions

1
examples/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
dub.selections.json

1
examples/client/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
client

10
examples/client/dub.json Normal file
View file

@ -0,0 +1,10 @@
{
"name": "client",
"homepage": "https://github.com/trishume/ddbus",
"copyright": "Copyright © 2017, Tristan Hume",
"authors": ["Tristan Hume"],
"targetType": "executable",
"dependencies": {
"ddbus": {"path": "../../"}
}
}

View file

@ -0,0 +1,21 @@
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 main() {
Connection conn = connectToBus();
testCall(conn);
writeln("It worked!");
}

1
examples/server/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
server

10
examples/server/dub.json Normal file
View file

@ -0,0 +1,10 @@
{
"name": "server",
"homepage": "https://github.com/trishume/ddbus",
"copyright": "Copyright © 2017, Tristan Hume",
"authors": ["Tristan Hume"],
"targetType": "executable",
"dependencies": {
"ddbus": {"path": "../../"}
}
}

View file

@ -1,19 +1,6 @@
import std.stdio; import std.stdio;
import ddbus; 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) { void testServe(Connection conn) {
auto router = new MessageRouter(); auto router = new MessageRouter();
MessagePattern patt = MessagePattern("/root","ca.thume.test","test"); MessagePattern patt = MessagePattern("/root","ca.thume.test","test");

View file

@ -1,3 +1,5 @@
module ddbus;
public import ddbus.thin; public import ddbus.thin;
public import ddbus.router; public import ddbus.router;
public import ddbus.bus; public import ddbus.bus;