From 9007eacdf328fdbbafbd14f8265641f7fca2617f Mon Sep 17 00:00:00 2001 From: Hiroki Noda Date: Sun, 3 Dec 2017 21:29:59 +0900 Subject: [PATCH 1/4] Create example directory and separate client/server. --- examples/.gitignore | 1 + examples/client/.gitignore | 1 + examples/client/dub.json | 10 ++++++++++ examples/client/source/client.d | 21 ++++++++++++++++++++ examples/server/.gitignore | 1 + examples/server/dub.json | 10 ++++++++++ example.d => examples/server/source/server.d | 13 ------------ source/ddbus/package.d | 2 ++ 8 files changed, 46 insertions(+), 13 deletions(-) create mode 100644 examples/.gitignore create mode 100644 examples/client/.gitignore create mode 100644 examples/client/dub.json create mode 100644 examples/client/source/client.d create mode 100644 examples/server/.gitignore create mode 100644 examples/server/dub.json rename example.d => examples/server/source/server.d (57%) diff --git a/examples/.gitignore b/examples/.gitignore new file mode 100644 index 0000000..37d50db --- /dev/null +++ b/examples/.gitignore @@ -0,0 +1 @@ +dub.selections.json diff --git a/examples/client/.gitignore b/examples/client/.gitignore new file mode 100644 index 0000000..b051c6c --- /dev/null +++ b/examples/client/.gitignore @@ -0,0 +1 @@ +client diff --git a/examples/client/dub.json b/examples/client/dub.json new file mode 100644 index 0000000..db79aa5 --- /dev/null +++ b/examples/client/dub.json @@ -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": "../../"} + } +} diff --git a/examples/client/source/client.d b/examples/client/source/client.d new file mode 100644 index 0000000..4b203a8 --- /dev/null +++ b/examples/client/source/client.d @@ -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!"); +} diff --git a/examples/server/.gitignore b/examples/server/.gitignore new file mode 100644 index 0000000..254defd --- /dev/null +++ b/examples/server/.gitignore @@ -0,0 +1 @@ +server diff --git a/examples/server/dub.json b/examples/server/dub.json new file mode 100644 index 0000000..8253938 --- /dev/null +++ b/examples/server/dub.json @@ -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": "../../"} + } +} diff --git a/example.d b/examples/server/source/server.d similarity index 57% rename from example.d rename to examples/server/source/server.d index 7904cd4..4c9c510 100644 --- a/example.d +++ b/examples/server/source/server.d @@ -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"); diff --git a/source/ddbus/package.d b/source/ddbus/package.d index ba0b271..095bd68 100644 --- a/source/ddbus/package.d +++ b/source/ddbus/package.d @@ -1,3 +1,5 @@ +module ddbus; + public import ddbus.thin; public import ddbus.router; public import ddbus.bus; From cc83591fce05a1f83e37467e93b08ae4e5ebf6b8 Mon Sep 17 00:00:00 2001 From: Hiroki Noda Date: Mon, 4 Dec 2017 05:59:18 +0900 Subject: [PATCH 2/4] Fix mixed in a tab. --- examples/client/source/client.d | 2 +- examples/server/source/server.d | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/client/source/client.d b/examples/client/source/client.d index 4b203a8..ef41da0 100644 --- a/examples/client/source/client.d +++ b/examples/client/source/client.d @@ -17,5 +17,5 @@ void testCall(Connection conn) { void main() { Connection conn = connectToBus(); testCall(conn); - writeln("It worked!"); + writeln("It worked!"); } diff --git a/examples/server/source/server.d b/examples/server/source/server.d index 4c9c510..0c4c0f7 100644 --- a/examples/server/source/server.d +++ b/examples/server/source/server.d @@ -22,5 +22,5 @@ void testServe(Connection conn) { void main() { Connection conn = connectToBus(); testServe(conn); - writeln("It worked!"); + writeln("It worked!"); } From a74a347645a2c588a2a32fa9116dc5f5fcc67e99 Mon Sep 17 00:00:00 2001 From: Hiroki Noda Date: Mon, 4 Dec 2017 06:04:28 +0900 Subject: [PATCH 3/4] Simplify dub.json to be able to easily copy the examples. --- examples/client/dub.json | 4 ---- examples/client/source/{client.d => app.d} | 0 examples/server/dub.json | 4 ---- examples/server/source/{server.d => app.d} | 0 4 files changed, 8 deletions(-) rename examples/client/source/{client.d => app.d} (100%) rename examples/server/source/{server.d => app.d} (100%) diff --git a/examples/client/dub.json b/examples/client/dub.json index db79aa5..672b7b3 100644 --- a/examples/client/dub.json +++ b/examples/client/dub.json @@ -1,9 +1,5 @@ { "name": "client", - "homepage": "https://github.com/trishume/ddbus", - "copyright": "Copyright © 2017, Tristan Hume", - "authors": ["Tristan Hume"], - "targetType": "executable", "dependencies": { "ddbus": {"path": "../../"} } diff --git a/examples/client/source/client.d b/examples/client/source/app.d similarity index 100% rename from examples/client/source/client.d rename to examples/client/source/app.d diff --git a/examples/server/dub.json b/examples/server/dub.json index 8253938..4594a92 100644 --- a/examples/server/dub.json +++ b/examples/server/dub.json @@ -1,9 +1,5 @@ { "name": "server", - "homepage": "https://github.com/trishume/ddbus", - "copyright": "Copyright © 2017, Tristan Hume", - "authors": ["Tristan Hume"], - "targetType": "executable", "dependencies": { "ddbus": {"path": "../../"} } diff --git a/examples/server/source/server.d b/examples/server/source/app.d similarity index 100% rename from examples/server/source/server.d rename to examples/server/source/app.d From 42a5ae0d3c982dabceb6e9e31da51f6fe99fbf11 Mon Sep 17 00:00:00 2001 From: Hiroki Noda Date: Thu, 7 Dec 2017 09:31:44 +0900 Subject: [PATCH 4/4] Use core.time.Duration. --- examples/client/source/app.d | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/client/source/app.d b/examples/client/source/app.d index ef41da0..a6055ab 100644 --- a/examples/client/source/app.d +++ b/examples/client/source/app.d @@ -1,3 +1,4 @@ +import core.time; import std.stdio; import ddbus; @@ -9,7 +10,7 @@ void testCall(Connection conn) { } Message msg2 = Message("ca.thume.transience","/ca/thume/transience/screensurface", "ca.thume.transience.screensurface","testPing"); - Message res = conn.sendWithReplyBlocking(msg2,3000); + Message res = conn.sendWithReplyBlocking(msg2, 3.seconds); int result = res.read!int(); writeln(result); }