Login to add login status judgment
This commit is contained in:
parent
79cbae718c
commit
5bdb9879a7
@ -53,5 +53,5 @@ dependencies {
|
||||
// 本地依赖,现将aar复制到libs/io/openim/core-sdk/0.0.1/ 下,命名core-sdk-0.0.1.aar
|
||||
// implementation 'io.openim:core-sdk:0.0.1@aar'
|
||||
// api 'io.openim:core-sdk:2.3.5-t44@aar'
|
||||
implementation 'io.openim:core-sdk:3.0.0-beta06@aar'
|
||||
implementation 'io.openim:core-sdk:3.0.0-beta08@aar'
|
||||
}
|
@ -7,6 +7,7 @@ export 'src/enum/group_type.dart';
|
||||
export 'src/enum/group_verification.dart';
|
||||
export 'src/enum/im_platform.dart';
|
||||
export 'src/enum/listener_type.dart';
|
||||
export 'src/enum/login_status.dart';
|
||||
export 'src/enum/message_status.dart';
|
||||
export 'src/enum/message_type.dart';
|
||||
export 'src/enum/sdk_error_code.dart';
|
||||
|
5
lib/src/enum/login_status.dart
Normal file
5
lib/src/enum/login_status.dart
Normal file
@ -0,0 +1,5 @@
|
||||
class LoginStatus {
|
||||
static const logout = 1;
|
||||
static const logging = 2;
|
||||
static const logged = 3;
|
||||
}
|
@ -8,7 +8,6 @@ class MessageFailedCode {
|
||||
|
||||
/// 已被移除群聊/群已解散
|
||||
static const int notInGroup = 1205;
|
||||
|
||||
}
|
||||
|
||||
/// 添加好友失败
|
||||
|
@ -73,13 +73,13 @@ class ConversationManager {
|
||||
}) =>
|
||||
_channel
|
||||
.invokeMethod(
|
||||
'getMultipleConversation',
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
'getMultipleConversation',
|
||||
_buildParam({
|
||||
"conversationIDList": conversationIDList,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
}))
|
||||
.then((value) =>
|
||||
Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
|
||||
Utils.toList(value, (map) => ConversationInfo.fromJson(map)));
|
||||
|
||||
/// 设置会话草稿
|
||||
/// [conversationID] 会话id
|
||||
@ -314,20 +314,20 @@ class ConversationManager {
|
||||
: a.latestMsgSendTime!;
|
||||
int bCompare = b.draftTextTime! > b.latestMsgSendTime!
|
||||
? b.draftTextTime!
|
||||
: b.latestMsgSendTime!;
|
||||
if (aCompare > bCompare) {
|
||||
return -1;
|
||||
} else if (aCompare < bCompare) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if (a.isPinned == true && b.isPinned != true) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
: b.latestMsgSendTime!;
|
||||
if (aCompare > bCompare) {
|
||||
return -1;
|
||||
} else if (aCompare < bCompare) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else if (a.isPinned == true && b.isPinned != true) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
static Map _buildParam(Map param) {
|
||||
param["ManagerName"] = "conversationManager";
|
||||
|
@ -467,10 +467,10 @@ class IMManager {
|
||||
required OnConnectListener listener,
|
||||
int logLevel = 6,
|
||||
String objectStorage = 'cos',
|
||||
String? encryptionKey,
|
||||
bool isNeedEncryption = false,
|
||||
bool isCompression = false,
|
||||
bool isExternalExtensions = false,
|
||||
// String? encryptionKey,
|
||||
// bool isNeedEncryption = false,
|
||||
// bool isCompression = false,
|
||||
// bool isExternalExtensions = false,
|
||||
bool isLogStandardOutput = true,
|
||||
String? logFilePath,
|
||||
String? operationID,
|
||||
@ -487,10 +487,10 @@ class IMManager {
|
||||
"dataDir": dataDir,
|
||||
"logLevel": logLevel,
|
||||
"objectStorage": objectStorage,
|
||||
"encryptionKey": encryptionKey,
|
||||
"isNeedEncryption": isNeedEncryption,
|
||||
"isCompression": isCompression,
|
||||
"isExternalExtensions": isExternalExtensions,
|
||||
// "encryptionKey": encryptionKey,
|
||||
// "isNeedEncryption": isNeedEncryption,
|
||||
// "isCompression": isCompression,
|
||||
// "isExternalExtensions": isExternalExtensions,
|
||||
"isLogStandardOutput": isLogStandardOutput,
|
||||
"logFilePath": logFilePath,
|
||||
"operationID": Utils.checkOperationID(operationID),
|
||||
@ -499,7 +499,7 @@ class IMManager {
|
||||
}
|
||||
|
||||
/// 登录
|
||||
/// [uid] 用户id
|
||||
/// [userID] 用户id
|
||||
/// [token] 登录token,从业务服务器上获取
|
||||
/// [defaultValue] 获取失败后使用的默认值
|
||||
Future<UserInfo> login({
|
||||
@ -507,15 +507,23 @@ class IMManager {
|
||||
required String token,
|
||||
String? operationID,
|
||||
Future<UserInfo> Function()? defaultValue,
|
||||
bool checkLoginStatus = true,
|
||||
}) async {
|
||||
await _channel.invokeMethod(
|
||||
'login',
|
||||
_buildParam({
|
||||
'userID': userID,
|
||||
'token': token,
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}),
|
||||
);
|
||||
int? status;
|
||||
if (checkLoginStatus) {
|
||||
// 1: logout 2: logging 3:logged
|
||||
status = await getLoginStatus();
|
||||
}
|
||||
if (status != LoginStatus.logging && status != LoginStatus.logged) {
|
||||
await _channel.invokeMethod(
|
||||
'login',
|
||||
_buildParam({
|
||||
'userID': userID,
|
||||
'token': token,
|
||||
'operationID': Utils.checkOperationID(operationID),
|
||||
}),
|
||||
);
|
||||
}
|
||||
this.isLogined = true;
|
||||
this.userID = userID;
|
||||
this.token = token;
|
||||
@ -544,6 +552,7 @@ class IMManager {
|
||||
}
|
||||
|
||||
/// 获取登录状态
|
||||
/// 1: logout 2: logging 3:logged
|
||||
Future<int?> getLoginStatus() =>
|
||||
_channel.invokeMethod<int>('getLoginStatus', _buildParam({}));
|
||||
|
||||
|
@ -145,7 +145,6 @@ class MessageManager {
|
||||
}))
|
||||
.then((value) => Utils.toObj(value, (map) => Message.fromJson(map)));
|
||||
|
||||
|
||||
/// 正在输入提示
|
||||
/// [msgTip] 自定义内容
|
||||
Future typingStatusUpdate({
|
||||
|
Loading…
x
Reference in New Issue
Block a user