im_lite_core_flutter 1.0.3 im_lite_core_flutter: ^1.0.3 copied to clipboard
Easy implementation of chat application based on imlite communication protocol!
import 'package:im_lite_core_flutter/im_lite_core_flutter.dart';
void main() async {
IMLiteCore.instance.init(
apiUrl: "http://api.dev-pi-zero.toowow.cn:10086",
wsUrl: "ws://api.dev-pi-zero.toowow.cn:10086",
autoPullTime: const Duration(seconds: 30),
connectListener: ConnectListener(
onConnecting: () {
// 连接中
print("连接中");
},
onSuccess: () {
// 连接成功
print("连接成功");
},
onError: (error) {
// 发生错误
print(error);
},
onClose: () {
// 连接关闭
print("连接关闭");
},
),
receiveConvListener: ReceiveConvListener(
onPullConv: (convList) {
if (convList != null) {
// 拉取会话列表
} else {
// 拉取会话错误
}
},
),
receiveMsgListener: ReceiveMsgListener(
onPushMsg: (msg) {
// 推送消息
},
),
);
await IMLiteCore.instance.login(
token:
"eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiIxNDgxMTgwNjEyMzc4MjYzNTUyIn0.qdaYuxIpq1wu3JyA8tPuy5zZNnYM2eC0k8z2UE9Cu2znI-XYkxZsBKx-WDTumPr1OF8Be3JU-q64FPn-Wzh6FuWYn883XvvWVs8tYT8GUpD3z-v0c_xHifWtXdQmbJlMfvVFLnamLHqWBp9IONsLs0AB9mg8VnCm9Y-cVD8TkMA",
userID: "1481180612378263552",
);
}