सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।
D-Bus संदेश बस क्लाइंट का एक मूल डार्ट वास्तुकला, जो डार्ट एप्लिकेशन को लिनक्स डेस्कटॉप सेवाओं के साथ सीधे संवाद करने की अनुमति देती है। यह पैकेज D-Bus के निचले स्तर की पहुंच प्रदान करता है, जिससे सिस्टम और एप्लिकेशन सेवाओं के साथ बातचीत की जा सकती है, जैसे सत्र प्रबंधन, हार्डवेयर घटनाएँ और डेस्कटॉप एकीकरण। यह लाइनक्स पर डेस्कटॉप एप्लिकेशन बनाने वाले विकासकर्ताओं के लिए डिज़ाइन किया गया है, जिसमें संगत D-Bus वास्तुकला के माध्यम से विंडोज और मैकओएस का समर्थन भी है। लाइब्रेरी D-Bus के माध्यम से संदेश भेजने और प्राप्त करने के लिए एक स्पष्ट, डार्ट-नेटिव API प्रदान करती है।
उपयोग
लिनक्स सिस्टम सेवाओं के साथ इंटरैक्ट करना
Dart ऐप्स में डेस्कटॉप फीचर्स को एकीकृत करना
हार्डवेयर और सत्र इवेंट की पहुंच
क्रॉस-प्लेटफ़ॉर्म डेस्कटॉप उपयोगिताएं बनाना
अन्य डेस्कटॉप एप्लिकेशन के साथ संचार सक्षम करना
मुख्य विशेषताएँ
मूल डार्ट डी-बस क्लाइंट
Linux डेस्कटॉप सेवाओं तक सीधी पहुँच
संदेश बस (सत्र और प्रणाली) के लिए समर्थन
क्रॉस-प्लेटफॉर्म संगतता (Linux, Windows, macOS)
स्पष्ट, असिंक्रोनस डार्ट API
इनके लिए उपयुक्त
Linux के लिए डेस्कटॉप ऐप विकासकर्ता
सिस्टम स्तरीय एकीकरण
डेस्कटॉप टूल्स बनाने वाले डार्ट विकासकर्ता
डेस्कटॉप सेवा संचार की आवश्यकता वाले अनुप्रयोग
निम्न-स्तरीय लिनक्स एकीकरण की आवश्यकता वाले प्रोजेक्ट
विचार योग्य बातें
मुख्य रूप से लिनक्स परिवेश के लिए उद्दिष्ट
मूल उपयोग के अतिरिक्त सीमित दस्तावेज़न
लक्ष्य प्रणालियों पर D-Bus डेमन की उपलब्धता की आवश्यकता है
Windows/macOS पर प्लेटफॉर्म-विशिष्ट कॉन्फ़िगरेशन की आवश्यकता हो सकती है
मोबाइल या वेब प्लेटफॉर्म के लिए उपयुक्त नहीं
मूल README
संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।
You can then use the generated test-remote-object.dart to access that remote object from your program:
import'package:dbus/dbus.dart';
import'test-remote-object.dart';
Future<void> main() async {
var client = DBusClient.session();
var object = ComExampleTestObject(client, 'com.example.Test');
var version = await object.getVersion();
print('version: $version');
var reversedText = await object.callReverseText('Hello World');
print(reversedText);
await client.close();
}
The code generated by dart-dbus may not be the cleanest API you want to expose for your service. It is recommended that you use the generated code as a starting point and then modify it as necessary.
Exporting local objects
The above interface definition can also be processed to generate a class for exporting this object.
You can also choose to access D-Bus objects directly without interface definitions and dbus-dart.
This requires writing more code and handing more error cases.
The following code shows how to access the remote object in the above examples:
import'package:dbus/dbus.dart';
Future<void> main() async {
var client = DBusClient.session();
var object = DBusRemoteObject(client, name: 'com.example.Test', path: DBusObjectPath('/com/example/Test/Object'));
var value = await object.getProperty('com.example.Test', 'Version', signature: DBusSignature('s'));
var version = value.asString();
print('version: $version');
var response = await object.callMethod('com.example.Test', 'ReverseText', [DBusString('Hello World')], replySignature: DBusSignature('s'));
var reversedText = response.values[0].asString();
print('$reversedText');
await client.close();
}
And the following shows how to export that object: