Merge pull request #31 from kubo39/exampledir

Create example directory and separate client/server.
This commit is contained in:
Jan Jurzitza 2017-12-07 19:45:49 +01:00 committed by GitHub
commit 1a5df56a42
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 40 additions and 14 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

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

@ -0,0 +1,6 @@
{
"name": "client",
"dependencies": {
"ddbus": {"path": "../../"}
}
}

View 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
View file

@ -0,0 +1 @@
server

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

@ -0,0 +1,6 @@
{
"name": "server",
"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");
@ -35,5 +22,5 @@ void testServe(Connection conn) {
void main() { void main() {
Connection conn = connectToBus(); Connection conn = connectToBus();
testServe(conn); testServe(conn);
writeln("It worked!"); writeln("It worked!");
} }

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;