Go to file
2024-09-20 14:58:00 +08:00
.vscode fix(#14 #12) 2023-12-02 03:20:23 +08:00
assets fix: Upgrade message protocol, add message extension topping function and the ability to send expired messages 2024-07-04 22:35:49 +08:00
example fix: After successfully modifying the synchronization channel message, no problem was returned 2024-09-20 14:58:00 +08:00
lib fix: After successfully modifying the synchronization channel message, no problem was returned 2024-09-20 14:58:00 +08:00
test first commit 2023-08-18 21:55:18 +08:00
.gitignore first commit 2023-08-18 21:55:18 +08:00
.metadata first commit 2023-08-18 21:55:18 +08:00
analysis_options.yaml first commit 2023-08-18 21:55:18 +08:00
CHANGELOG.md fix: After successfully modifying the synchronization channel message, no problem was returned 2024-09-20 14:58:00 +08:00
LICENSE update LICENSE 2023-08-21 09:39:09 +08:00
pubspec.lock fix: Modifying messages sent by oneself will increase the issue of unread quantity 2024-06-05 18:01:44 +08:00
pubspec.yaml fix: After successfully modifying the synchronization channel message, no problem was returned 2024-09-20 14:58:00 +08:00
README.md fix:upgrade proto Version 2024-08-02 21:31:47 +08:00

悟空IM Flutter SDK

悟空IM flutter sdk 源码 详细文档

快速入门

安装

pub package

dependencies:
  wukongimfluttersdk: ^version // 版本号看上面

引入

import 'package:wukongimfluttersdk/wkim.dart';

初始化sdk

WKIM.shared.setup(Options.newDefault('uid', 'token'));

初始化IP

WKIM.shared.options.getAddr = (Function(String address) complete) async {
    // 可通过接口获取后返回
      String ip = await HttpUtils.getIP();
      complete(ip);
    };

连接

WKIM.shared.connectionManager.connect();

断开

// isLogout true退出并不再重连 false退出保持重连
WKIM.shared.connectionManager.disconnect(isLogout)

发消息

WKIM.shared.messageManager.sendMessage(WKTextContent('我是文本消息'), WKChannel(channelID, channelType));

监听

连接监听

WKIM.shared.connectionManager.addOnConnectionStatus('home',
        (status, reason,connectInfo) {
      if (status == WKConnectStatus.connecting) {
        // 连接中
      } else if (status == WKConnectStatus.success) {
        var nodeId = connectInfo?.nodeId; // 节点id
        // 成功
      } else if (status == WKConnectStatus.noNetwork) {
        // 网络异常
      } else if (status == WKConnectStatus.syncMsg) {
        //同步消息中
      } else if (status == WKConnectStatus.syncCompleted) {
        //同步完成
      }
    });

消息入库

WKIM.shared.messageManager.addOnMsgInsertedListener((wkMsg) {
      // todo 展示在UI上
    });

收到新消息

WKIM.shared.messageManager.addOnNewMsgListener('chat', (msgs) {
      // todo 展示在UI上
    });

刷新某条消息

WKIM.shared.messageManager.addOnRefreshMsgListener('chat', (wkMsg) {
      // todo 刷新消息
    });

命令消息(cmd)监听

WKIM.shared.cmdManager.addOnCmdListener('chat', (cmdMsg) {
    // todo 按需处理cmd消息
});
  • 包含key的事件监听均有移除监听的方法,为了避免重复收到事件回掉,在退出或销毁页面时通过传入的key移除事件

许可证

悟空IM 使用 Apache 2.0 许可证。有关详情,请参阅 LICENSE 文件。