Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added support for no reply methods #50

Merged
merged 2 commits into from
Mar 2, 2020
Merged

Conversation

shannon
Copy link
Contributor

@shannon shannon commented Feb 17, 2020

I was working with the bluez dbus api and there are several methods that error with AccessDenied because they are not expecting a reply at all. So to avoid having to add a customer handler for all the methods I added simple way to indicate that a method does not need to send a reply.

Example

@method({inSignature: '', outSignature: null})
MethodWithNoReply() {

}

I thought you might be interested in this because this use case is called out in the readme for the customer message handler.

@acrisci
Copy link
Member

acrisci commented Feb 17, 2020

Interesting idea. We can support this, but I don't like the idea of differentiating empty string and null like this. Instead add noReply: true as a parameter to the method. Then add the annotation org.freedesktop.DBus.Method.NoReply to the method in the introspection (see the spec section called Introspection Data Format). This should also be handled in the client.

@shannon
Copy link
Contributor Author

shannon commented Feb 17, 2020

Fair enough, I originally had it that way but then the outSignature seemed redundant so I switched it to null. But this is more readable.

I have updated the PR.

New Example:

@method({inSignature: '', outSignature: '', noReply: true})
MethodWithNoReply() {

}

I added a test but I wasn't actually able to run the test. I kept getting No tests found, exiting with code 1 when running npm run unit. I don't know if there is some trick to get it to work.

@acrisci
Copy link
Member

acrisci commented Feb 17, 2020

Use npm run test.

@shannon
Copy link
Contributor Author

shannon commented Feb 17, 2020

Yea, sorry it gives the same error. I tried a few different environments, ubuntu, windows, on my raspberry pi itself. All gave the same error.

> dbus-run-session -- jest

No tests found, exiting with code 1
Run with `--passWithNoTests` to exit with code 0
No files found in /home/totem/projects/totem-gateway/node_modules/dbus-next.
Make sure Jest's configuration does not exclude this directory.
To set up Jest, make sure a package.json file exists.
Jest Documentation: facebook.github.io/jest/docs/configuration.html
Pattern:  - 0 matches
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] test: `dbus-run-session -- jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/totem/.npm/_logs/2020-02-17T22_56_27_898Z-debug.log

I'm not super familiar with jest so I assume I must be doing something wrong. I don't know why it's saying there are no matches when the files are clearly there:

ls test/*.test.js -la
-rw-r--r-- 1 totem totem 4080 Feb 17 21:45 test/introspection.test.js
-rw-r--r-- 1 totem totem 1809 Feb 17 16:35 test/validators.test.js

@shannon
Copy link
Contributor Author

shannon commented Feb 17, 2020

I figured it out, it didn't like me running them from inside node_modules. They are running now.

@shannon
Copy link
Contributor Author

shannon commented Feb 17, 2020

So they all passed.

totem@totempi:~/node-dbus-next $  npm run test

> [email protected] test /home/totem/node-dbus-next
> dbus-run-session -- jest

 PASS  test/integration/properties.test.js (59.487s)
 PASS  test/integration/signals.test.js (7.916s)
 PASS  test/integration/low-level.test.js (6.093s)
 PASS  test/introspection.test.js (6.483s)
 PASS  test/integration/methods.test.js (7.228s)
 PASS  test/integration/service-options.test.js (6.687s)
 PASS  test/integration/long-compat.test.js (5.559s)
 PASS  test/integration/client-standard-dbus.test.js

 PASS  test/integration/monitor.test.js

 PASS  test/integration/long.test.js (5.598s)
 PASS  test/integration/configured-service.test.js
 PASS  test/integration/request-name.test.js
 PASS  test/integration/service-errors.test.js (5.907s)
 PASS  test/validators.test.js

Test Suites: 14 passed, 14 total
Tests:       32 passed, 32 total
Snapshots:   0 total
Time:        131.55s
Ran all test suites.

One thing I did want to mention, the reason I added the test was I wasn't sure where you were converting the introspection json to actual XML, so I wasn't sure if I was doing it right. So that led me to the tests but the tests don't actually do this either.

@acrisci
Copy link
Member

acrisci commented Feb 21, 2020

Yeah it works fine. It just needs some documentation and it's good.

@shannon
Copy link
Contributor Author

shannon commented Feb 22, 2020

Let me know if that latest commit is ok, or if you were looking for something else.

@acrisci
Copy link
Member

acrisci commented Mar 2, 2020

Yeah that's ok. 👍 .

@acrisci acrisci merged commit 6cb208c into dbusjs:master Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants