पैकेज, रिपॉज़िटरी और ऐप श्रेणियाँ खोजें

पैकेज विवरणv1.1.0

deeplink_rpc

Dart में लिखा गया एक RPC-विया-डीपलिंक संचार पुस्तकालय। इसका उपयोग फ्लटर मोबाइल एप्लिकेशन (iOS / Android) के लिए किया जाता है।

AndroidiOSmacOSWindowsLinux
30-दिन डाउनलोड
142
लाइक
4
Pub अंक
130

पैकेज इंस्टॉल करें

flutter pub add deeplink_rpc

पैकेज अवलोकन

सार्वजनिक जानकारी से बना चयन मार्गदर्शन। केवल संदर्भ हेतु।

एक डार्ट-आधारित प per जो आईओएस और एंड्रॉइड के लिए फ्लटर एप्लिकेशन में गहरे लिंक के माध्यम से RPC (रिमोट प्रोसीजर कॉल) संचार की अनुमति देता है। यह गहरे लिंक URL का उपयोग करके ऐप्स के बीच या एक ही ऐप के घटकों के बीच विधियों को आह्वान करने और डेटा के आदान-प्रदान करने के माध्यम से सुरक्षित, क्रॉस-प्लेटफॉर्म अंतर-ऐप संचार को सुविधाजनक बनाता है। यह मोबाइल वातावरण के साथ बिना किसी बाधा के एकीकरण के लिए डिज़ाइन किया गया है, संरचित संदेश प्रसारण का समर्थन करता है और ऐप-से-ऐप इंटरैक्शन की आवश्यकता वाले मामलों के लिए आदर्श है जो पारंपरिक नेटवर्क कॉल पर निर्भर नहीं है। यह पुस्तकालय ओपन-सोर्स है और Archethic Foundation द्वारा बनाए रखा जाता है।

उपयोग

  • एप्प-टू-एप्प संचार
  • Flutter ऐप में एंटरमॉड्यूल संदेश प्रेषण
  • सुरक्षित रिमोट मेथड कॉल
  • गहरे लिंक के माध्यम से बाहरी क्रियाओं का प्रबंधन
  • डेटा स्थानांतरण के साथ सरल नेविगेशन

मुख्य विशेषताएँ

  • गहरे लिंक-आधारित RPC
  • क्रॉस-प्लेटफ़ॉर्म समर्थन (iOS/Android)
  • सुरक्षित संदेश अनुक्रमण
  • Flutter के साथ आसान एकीकरण
  • ओपन-सोर्स और सक्रिय रूप से बनाए रखा जा रहा है

इनके लिए उपयुक्त

  • Flutter का उपयोग करने वाले मोबाइल ऐप डेवलपर्स
  • अंतर-एप्लिकेशन संचार की आवश्यकता वाले एप्लिकेशन
  • सुरक्षित डीप लिंक वर्कफ़्लो का कार्यान्वयन करने वाले विकासकर्मी
  • हल्के RPC विकल्प की आवश्यकता वाले प्रोजेक्ट
  • मॉड्यूलर या माइक्रो-फ्रंटएंड आर्किटेक्चर बनाने वाली टीमें

विचार योग्य बातें

  • लक्षित प्लेटफॉर्म पर सही डीप लिंक कॉन्फ़िगरेशन की आवश्यकता होती है
  • मोबाइल और डेस्कटॉप प्लेटफॉर्म के लिए सीमित (वेब नहीं)
  • सही URL योजना सेटअप पर निर्भर करता है
  • संवेदनशील डेटा के लिए अतिरिक्त सुरक्षा उपायों की आवश्यकता हो सकती है
  • उच्च आवृत्ति या कम लेटेंसी संचार के लिए उपयुक्त नहीं

मूल README

संबंधित सोर्स रिपॉज़िटरी के मूल README का स्नैपशॉट। नवीनतम सामग्री के लिए रिपॉज़िटरी देखें।

Deeplink RPC

A RPC-via-deeplink communication library coded in Dart. This is dedicated to Flutter mobile applications (iOS / Android).

Protocol

Deeplink codec

Deeplink messages are appended to the deeplink URI. Because of that, there are limitations in the available formatting.

To get it working, the message is encoded that way :

                     +--------------+   +------+   +-----------+
method_payload :     | Json Message |-> | gzip |-> | base64Url |
                     +--------------+   +------+   +-----------+


Deeplink Url : `<scheme>://<host>/<method_name>/<method_payload>`

Example :

                     +--------------------------+      +----------------------------------------------------------------+
method_payload :     | { "param1" : "a_value" } |----> | "H4sIAAAAAAAAA6tWUCpILErMNVRSsFJQSowvS8wpTVVSqAUAhIgKchgAAAA=" |
                     +--------------------------+      +----------------------------------------------------------------+


Deeplink Url : `scheme://host/a_method/H4sIAAAAAAAAA6tWUCpILErMNVRSsFJQSowvS8wpTVVSqAUAhIgKchgAAAA=`

Request formatting

Requests payload are encapsulated in a JSON-RPC 2.0 message.

{
  "id": Number,                     // An unique client-generated integer identifying the request
  "replyUrl": String,               // Deeplink URL to which send the invokation result. This should be a Deeplink URL handled by the DApp.
  "params": {
    "origin": {
      "name": String,               // Human readable identifier of the DApp
      "url": String | undefined,    // URL of the DApp
      "logo": Base64 | undefined,   // Logo of the DApp 
    },
    "version": 2,                   // Version of the DApp API
    "payload": Object,              // Method parameters
  }
}
Success Response formatting
{
  "id": Number,                     // The request identifier
  "result":  Object,                // Result payload
}
Failure Response formatting
{
  "id": Number,                     // The request identifier
  "failure": {
    "code": Number,                 // Error code
    "message": String | undefined,  // Error description
    "data": Object | undefined,     // Error data
  },
}

Usage

Server - listening to incoming requests
/// 1. Enable deeplinking for your application (https://docs.flutter.dev/development/ui/navigation/deep-linking)

/// 2. Declare the deeplink-rpc receiver
/// When a RPC call <scheme>://a_rpc_command/<payload> is received, the payload is decoded
/// and transmitted to the `handle` method.
final _deeplinkRpcServer = DeeplinkRpcServer()
    ..registerHandler(
      DeeplinkRpcRequestHandler(
        route: const DeeplinkRpcRoute('a_rpc_command'),
        handle: (request) {
            log('Command received');
        }
      ),
    );


class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'DeeplinkRPC Demo',
      home: const SendForm(),
      onGenerateRoute: (settings) {
        /// 3. Listen to incoming deeplink requests
        if (_deeplinkRpcServer.handleRoute(settings.name)) return;

        // ... do other route generation stuffs here.
        return null;
      },
    );
  }
}
Client - Sending requests and listening for responses
/// 1. Enable deeplinking for your application (https://docs.flutter.dev/development/ui/navigation/deep-linking)
/// It is necessary to receive responses.

/// 2. Declare the deeplink-rpc client
/// When a RPC call <scheme>://a_rpc_command/<payload> is received, the payload is decoded
/// and transmitted to the `handle` method.
final _deeplinkRpcClient = DeeplinkRpcClient();

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'DeeplinkRPC Demo',
      onGenerateRoute: (settings) {
        /// 3. Listen to incoming deeplink requests
        if (_deeplinkRpcClient.handleRoute(settings.name)) return;

        // ... do other route generation stuffs here.
        return null;
      },
      home: Scaffold(
        floatingActionButton: FloatingActionButton(
          child: const Icon(Icons.send),
          onPressed: () async {
            final response = await _deeplinkRpcClient.send(
              timeout: const Duration(seconds: 5),
              request: DeeplinkRpcRequest(
                requestUrl: 'serverapp://server.app/request_endpoint',
                replyUrl: 'clientapp://client.app/reply_endpoint',
                params: {
                  'param1': 'value1',
                  'param2': 'value2',
                },
              ),
            );

            response.map(
              failure: (failure) {
                log(
                  'RPC request failed',
                  error: failure,
                );
                ScaffoldMessenger.of(context).showSnackBar(
                  SnackBar(
                      content: Text(failure.message ?? "An error occured")),
                );
              },
              success: (result) {
                log(
                  'RPC request succeed : ${json.encode(result)}',
                );
                ScaffoldMessenger.of(context).showSnackBar(
                  SnackBar(content: Text(json.encode(result))),
                );
              },
            );
          },
        ),
        body: const SafeArea(
          child: Padding(
            padding: EdgeInsets.all(8.0),
            child: Center(
              child: Text('Client example'),
            ),
          ),
        ),
      ),
    );
  }
}

श्रेणियाँ

निर्भरताएँ

निर्भरता सूची 6 आइटम

सोर्स रिपॉज़िटरी

इस पैकेज का उपयोग करने वाले प्रोजेक्ट