Create example directory and separate client/server.
This commit is contained in:
parent
ce7716463d
commit
9007eacdf3
8 changed files with 46 additions and 13 deletions
1
examples/server/.gitignore
vendored
Normal file
1
examples/server/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
server
|
10
examples/server/dub.json
Normal file
10
examples/server/dub.json
Normal 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": "../../"}
|
||||
}
|
||||
}
|
26
examples/server/source/server.d
Normal file
26
examples/server/source/server.d
Normal file
|
@ -0,0 +1,26 @@
|
|||
import std.stdio;
|
||||
import ddbus;
|
||||
|
||||
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;
|
||||
});
|
||||
patt = MessagePattern("/signaler","ca.thume.test","signal",true);
|
||||
router.setHandler!(void,int)(patt,(int par) {
|
||||
writeln("Signalled with ", par);
|
||||
});
|
||||
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);
|
||||
writeln("It worked!");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue