{"id":32307009,"url":"https://github.com/dimchat/sdk-dart","last_synced_at":"2026-02-19T21:56:04.371Z","repository":{"id":151754009,"uuid":"623931382","full_name":"dimchat/sdk-dart","owner":"dimchat","description":"Decentralized Instant Messaging (Dart SDK)","archived":false,"fork":false,"pushed_at":"2026-01-11T12:08:32.000Z","size":428,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-01-11T16:40:47.040Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dimchat.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-04-05T11:48:34.000Z","updated_at":"2026-01-11T12:08:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"47792697-f20c-49a3-8a38-671212b3c727","html_url":"https://github.com/dimchat/sdk-dart","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/dimchat/sdk-dart","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fsdk-dart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fsdk-dart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fsdk-dart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fsdk-dart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dimchat","download_url":"https://codeload.github.com/dimchat/sdk-dart/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dimchat%2Fsdk-dart/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29634493,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-19T18:02:07.722Z","status":"ssl_error","status_checked_at":"2026-02-19T18:01:46.144Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-10-23T07:13:19.341Z","updated_at":"2026-02-19T21:56:04.366Z","avatar_url":"https://github.com/dimchat.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Decentralized Instant Messaging (Dart SDK)\n\n[![License](https://img.shields.io/github/license/dimchat/sdk-dart)](https://github.com/dimchat/sdk-dart/blob/main/LICENSE)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/dimchat/sdk-dart/pulls)\n[![Platform](https://img.shields.io/badge/Platform-Dart%203-brightgreen.svg)](https://github.com/dimchat/sdk-dart/wiki)\n[![Issues](https://img.shields.io/github/issues/dimchat/sdk-dart)](https://github.com/dimchat/sdk-dart/issues)\n[![Repo Size](https://img.shields.io/github/repo-size/dimchat/sdk-dart)](https://github.com/dimchat/sdk-dart/archive/refs/heads/main.zip)\n[![Tags](https://img.shields.io/github/tag/dimchat/sdk-dart)](https://github.com/dimchat/sdk-dart/tags)\n[![Version](https://img.shields.io/pub/v/dimsdk)](https://pub.dev/packages/dimsdk)\n\n[![Watchers](https://img.shields.io/github/watchers/dimchat/sdk-dart)](https://github.com/dimchat/sdk-dart/watchers)\n[![Forks](https://img.shields.io/github/forks/dimchat/sdk-dart)](https://github.com/dimchat/sdk-dart/forks)\n[![Stars](https://img.shields.io/github/stars/dimchat/sdk-dart)](https://github.com/dimchat/sdk-dart/stargazers)\n[![Followers](https://img.shields.io/github/followers/dimchat)](https://github.com/orgs/dimchat/followers)\n\n## Dependencies\n\n* Latest Versions\n\n| Name | Version | Description |\n|------|---------|-------------|\n| [Ming Ke Ming (名可名)](https://github.com/dimchat/mkm-dart) | [![Version](https://img.shields.io/pub/v/mkm)](https://pub.dev/packages/mkm) | Decentralized User Identity Authentication |\n| [Dao Ke Dao (道可道)](https://github.com/dimchat/dkd-dart) | [![Version](https://img.shields.io/pub/v/dkd)](https://pub.dev/packages/dkd) | Universal Message Module |\n| [DIMP (去中心化通讯协议)](https://github.com/dimchat/core-dart) | [![Version](https://img.shields.io/pub/v/dimp)](https://pub.dev/packages/dimp) | Decentralized Instant Messaging Protocol |\n\n## Extensions\n\n### Content\n\nextends [CustomizedContent](https://github.com/dimchat/core-dart#extends-content)\n\n### ContentProcessor\n\n```dart\nimport 'package:dimsdk/dimsdk.dart';\n\n\n///  Customized Content Processing Unit\n///  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n///  Handle content for application customized\nclass AppCustomizedProcessor extends CustomizedContentProcessor {\n  AppCustomizedProcessor(super.facebook, super.messenger);\n\n  final Map\u003cString, CustomizedContentHandler\u003e _handlers = {};\n\n  void setContentHandler({\n    required String app, required String mod,\n    required CustomizedContentHandler handler\n  }) =\u003e _handlers['$app:$mod'] = handler;\n\n  // protected\n  CustomizedContentHandler? getContentHandler({\n    required String app, required String mod,\n  }) =\u003e _handlers['$app:$mod'];\n\n  /// override for your modules\n  @override\n  CustomizedContentHandler filter(String app, String mod, CustomizedContent content, ReliableMessage rMsg) {\n    CustomizedContentHandler? handler = getContentHandler(app: app, mod: mod);\n    if (handler != null) {\n      return handler;\n    }\n    // default handler\n    return super.filter(app, mod, content, rMsg);\n  }\n\n}\n```\n\n```dart\nimport 'package:dimsdk/dimsdk.dart';\n\nimport '../../common/protocol/groups.dart';\n\n\n/*  Command Transform:\n\n    +===============================+===============================+\n    |      Customized Content       |      Group Query Command      |\n    +-------------------------------+-------------------------------+\n    |   \"type\" : i2s(0xCC)          |   \"type\" : i2s(0x88)          |\n    |   \"sn\"   : 123                |   \"sn\"   : 123                |\n    |   \"time\" : 123.456            |   \"time\" : 123.456            |\n    |   \"app\"  : \"chat.dim.group\"   |                               |\n    |   \"mod\"  : \"history\"          |                               |\n    |   \"act\"  : \"query\"            |                               |\n    |                               |   \"command\"   : \"query\"       |\n    |   \"group\"     : \"{GROUP_ID}\"  |   \"group\"     : \"{GROUP_ID}\"  |\n    |   \"last_time\" : 0             |   \"last_time\" : 0             |\n    +===============================+===============================+\n */\nclass GroupHistoryHandler extends BaseCustomizedHandler {\n  GroupHistoryHandler(super.facebook, super.messenger);\n\n  @override\n  Future\u003cList\u003cContent\u003e\u003e handleAction(String act, ID sender, CustomizedContent content, ReliableMessage rMsg) async {\n    if (content.group == null) {\n      assert(false, 'group command error: $content, sender: $sender');\n      String text = 'Group command error.';\n      return respondReceipt(text, envelope: rMsg.envelope, content: content);\n    } else if (GroupHistory.ACT_QUERY == act) {\n      assert(GroupHistory.APP == content.application);\n      assert(GroupHistory.MOD == content.module);\n      return await transformQueryCommand(content, rMsg);\n    }\n    assert(false, 'unknown action: $act, $content, sender: $sender');\n    return await super.handleAction(act, sender, content, rMsg);\n  }\n\n  // private\n  Future\u003cList\u003cContent\u003e\u003e transformQueryCommand(CustomizedContent content, ReliableMessage rMsg) async {\n    var transceiver = messenger;\n    if (transceiver == null) {\n      assert(false, 'messenger lost');\n      return [];\n    }\n    Map info = content.copyMap(false);\n    info['type'] = ContentType.COMMAND;\n    info['command'] = GroupCommand.QUERY;\n    Content? query = Content.parse(info);\n    if (query is QueryCommand) {\n      return await transceiver.processContent(query, rMsg);\n    }\n    assert(false, 'query command error: $query, $content, sender: ${rMsg.sender}');\n    String text = 'Query command error.';\n    return respondReceipt(text, envelope: rMsg.envelope, content: content);\n  }\n\n}\n```\n\n### ContentProcessorCreator\n\n```dart\nimport 'package:dimsdk/dimsdk.dart';\n\nimport 'customized.dart';\nimport 'handshake.dart';\n\n\nclass ClientContentProcessorCreator extends BaseContentProcessorCreator {\n  ClientContentProcessorCreator(super.facebook, super.messenger);\n\n  // protected\n  AppCustomizedProcessor createCustomizedContentProcessor(Facebook facebook, Messenger messenger) {\n    var cpu = AppCustomizedProcessor(facebook, messenger);\n    \n    // 'chat.dim.group:history'\n    cpu.setContentHandler(\n      app: GroupHistory.APP,\n      mod: GroupHistory.MOD,\n      handler: GroupHistoryHandler(facebook, messenger),\n    );\n    \n    return cpu;\n  }\n\n  @override\n  ContentProcessor? createContentProcessor(String msgType) {\n    switch (msgType) {\n\n      // application customized\n      case ContentType.APPLICATION:\n      case 'application':\n      case ContentType.CUSTOMIZED:\n      case 'customized':\n        return createCustomizedContentProcessor(facebook!, messenger!);\n\n      // ...\n    }\n    // others\n    return super.createContentProcessor(msgType);\n  }\n\n  @override\n  ContentProcessor? createCommandProcessor(String msgType, String cmd) {\n    switch (cmd) {\n    \n      case HandshakeCommand.HANDSHAKE:\n        return HandshakeCommandProcessor(facebook!, messenger!);\n        \n      // ...\n    }\n    // others\n    return super.createCommandProcessor(msgType, cmd);\n  }\n\n}\n```\n\n## Usage\n\nTo let your **AppCustomizedProcessor** start to work,\nyou must override ```BaseContentProcessorCreator``` for message types:\n\n1. ContentType.APPLICATION \n2. ContentType.CUSTOMIZED\n\nand then set your **creator** for ```GeneralContentProcessorFactory``` in the ```MessageProcessor```.\n\n----\n\nCopyright \u0026copy; 2023-2026 Albert Moky\n[![Followers](https://img.shields.io/github/followers/moky)](https://github.com/moky?tab=followers)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimchat%2Fsdk-dart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdimchat%2Fsdk-dart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdimchat%2Fsdk-dart/lists"}