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

New high-level client and service interfaces #251

Open
wants to merge 10 commits into
base: master
from

Conversation

Projects
None yet
3 participants
@acrisci
Copy link

commented Nov 18, 2018

Changes from my fork, dbus-next.

I use some ES6 stuff like destructuring and classes which might require bumping the required node version up to 6.0.

But other than that, no breaking changes! All the new interfaces are built on top of the existing low level interfaces and should not interfere with any of the existing code. Only 8 lines have been removed with minimal logic changes.

The README includes examples of the new interfaces.

Check out the new mpris controller script for a complete example of the client in action and doing something useful.

There's also a working example of the service interface.

All the new interfaces have very good integration tests which use a real dbus connection to test both the client and the service at the same time.

Run integration tests:

npm run integration

Coverage of the new interfaces is about 87 percent:

npm run coverage

acrisci added some commits Nov 2, 2018

Redesign the service interface
* Add the Interface class to be extended to create interfaces
* Add property, signal, and method decorators for interface members
* Add a new Variant() class for specifying variant types
* Add bus.export() method to export new interfaces
* Add validators for object path, interface, and member names
* Implement standard interfaces for services
* Add example project to demo the new interface design
Merge pull request #1 from acrisci/next
Service interface redesign
implement the new client interface
Add `bus.getProxyObject()` to get a proxy object for an object on the
bus. The proxy object contains introspection data for the object
including the nodes and interfaces.

Interfaces can be gotten with `object.getInterface()` with the name of
the interface. The interface includes methods to call on the bus based
on the introspection data.

The interface is an event emitter which emits signals for the object on
the bus.

See the new mpris.js example and the README for more details.
Merge pull request #5 from acrisci/next-client
implement the new client interface
add integration tests
Integration tests test the client and the server interfaces together on
a real bus. Run integration tests with `npm run integration`.

This commit also includes fixes for bugs that were found while writing
the tests.
implement unexporting names, paths, and interfaces
Add methods and tests for unexporting things.

* `unexportName()` - unexports all paths and interfaces on the name and
releases the name from the bus
* `unexportPath()` - unexports all interfaces from the path
* `unexportInterface()` - unexports the interface from the path
@Sun1ive

This comment has been minimized.

Copy link

commented Jan 30, 2019

any news on this?

@acrisci

This comment has been minimized.

Copy link
Author

commented Jan 30, 2019

@Sun1ive I've released dbus-next on npm so people can start using it now if they want.

https://www.npmjs.com/package/dbus-next

@Sun1ive

This comment has been minimized.

Copy link

commented Jan 31, 2019

@Sun1ive I've released dbus-next on npm so people can start using it now if they want.

https://www.npmjs.com/package/dbus-next

thank you! ill give it a try

@CyDragon80

This comment has been minimized.

Copy link

commented Feb 5, 2019

Just a random thought, if this new interface is entirely optional, is it possible to simply hide it in versions less than node 7 and expose it in newer versions using the dynamic nature of javascript. By hiding 7+ language features in modules that are only brought in if node is 7+, one might be able to avoid throwing errors in older node in theory. Whether it's worth the extra transitional code or best to wait for the next major package rev is certainly debatable, but thought I'd mention it in case it's of any use to anyone.

function getNodeMajor()
{
    var reg = /^[^\d]*(\d+)/;
    var temp = reg.exec(process.version);
    return (temp==null||temp[1]==null?0:parseInt(temp[1]));
}
module.exports.NodeMajor = getNodeMajor(); // only need to compute once
. . .
if (module.exports.NodeMajor >= 7)
{
    // new feature just for 7+
    const OptionalBit = require('optional-bit'); // module containing newer language features
    module.exports.newThing = OptionalBit.newThing; // new package feature export
    // etc etc
}
else
{
    // fallback if any? or leave new stuff undefined?
    module.exports.newThing = null; // ?
    module.exports.newThing = function() { throw new Error('Feature needs Node 7+')}; // ?
}

@acrisci acrisci referenced this pull request Feb 5, 2019

Closed

Support earlier node versions #6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.