Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
114980dab0 | ||
|
|
1af1ecfbb9 |
@@ -23,24 +23,26 @@ class _MyAppState extends State<MyApp> {
|
|||||||
super.initState();
|
super.initState();
|
||||||
OpenIM.iMManager
|
OpenIM.iMManager
|
||||||
.initSDK(
|
.initSDK(
|
||||||
platformID: 2,
|
platformID: 3,
|
||||||
apiAddr: 'http://192.168.77.135:10002',
|
apiAddr: 'http://192.168.77.135:10002',
|
||||||
wsAddr: 'ws://192.168.77.135:10001',
|
wsAddr: 'ws://192.168.77.135:10001',
|
||||||
dataDir: './',
|
dataDir: './',
|
||||||
listener: OnConnectListener())
|
listener: OnConnectListener())
|
||||||
.then((value) {
|
.then((value) {});
|
||||||
print('SDK initialized successfully');
|
OpenIM.iMManager.userManager.setUserListener(OnUserListener());
|
||||||
|
|
||||||
OpenIM.iMManager
|
OpenIM.iMManager
|
||||||
.login(
|
.login(
|
||||||
userID: "3e8b8fb2ecd8414db50838d9f7bcb19d",
|
userID: "8bfe13b5eac44e87963652abb91d80d2",
|
||||||
token:
|
token:
|
||||||
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOiIzZThiOGZiMmVjZDg0MTRkYjUwODM4ZDlmN2JjYjE5ZCIsIlBsYXRmb3JtSUQiOjIsImV4cCI6MTc1Mzc1MTYyNywiaWF0IjoxNzQ1OTc1NjIyfQ.S-CxfETXYyLFe2VqStwbrVCRcB5j2T2qi-52y1L-3OI")
|
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOiI4YmZlMTNiNWVhYzQ0ZTg3OTYzNjUyYWJiOTFkODBkMiIsIlBsYXRmb3JtSUQiOjMsImV4cCI6MTc1NDM2NDkwNCwiaWF0IjoxNzQ2NTg4ODk5fQ.575xwR9lzJo1i5Te-Ul-99odONfxbzDXW0_2Kv3nFEE")
|
||||||
.then((value) {
|
.then((value) {
|
||||||
print('Login successful');
|
OpenIM.iMManager.conversationManager
|
||||||
}).catchError((error) {
|
.getAllConversationList()
|
||||||
print('Login failed: $error');
|
.then((value) {
|
||||||
});
|
print('Get all conversation list successful');
|
||||||
});
|
});
|
||||||
|
}).catchError((error) {});
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|||||||
@@ -14,13 +14,6 @@ namespace ThreadUtil {
|
|||||||
static std::condition_variable g_queueCondition;
|
static std::condition_variable g_queueCondition;
|
||||||
static bool g_initialized = false;
|
static bool g_initialized = false;
|
||||||
static HANDLE g_workerThread = NULL;
|
static HANDLE g_workerThread = NULL;
|
||||||
|
|
||||||
// Function to initialize the platform thread ID
|
|
||||||
void InitializePlatformThreadId() {
|
|
||||||
g_platformThreadId = GetCurrentThreadId();
|
|
||||||
g_initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Worker thread function
|
// Worker thread function
|
||||||
unsigned __stdcall WorkerThreadProc(void* param) {
|
unsigned __stdcall WorkerThreadProc(void* param) {
|
||||||
while (true) {
|
while (true) {
|
||||||
@@ -39,6 +32,16 @@ namespace ThreadUtil {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
// Function to initialize the platform thread ID
|
||||||
|
void InitializePlatformThreadId() {
|
||||||
|
g_platformThreadId = GetCurrentThreadId();
|
||||||
|
|
||||||
|
// Create worker thread
|
||||||
|
g_workerThread = (HANDLE)_beginthreadex(NULL, 0, WorkerThreadProc, NULL, 0, NULL);
|
||||||
|
g_initialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Function to ensure code runs on the platform thread
|
// Function to ensure code runs on the platform thread
|
||||||
void RunOnPlatformThread(std::function<void()> callback) {
|
void RunOnPlatformThread(std::function<void()> callback) {
|
||||||
@@ -46,8 +49,7 @@ namespace ThreadUtil {
|
|||||||
if (!g_initialized) {
|
if (!g_initialized) {
|
||||||
InitializePlatformThreadId();
|
InitializePlatformThreadId();
|
||||||
|
|
||||||
// Create worker thread
|
|
||||||
g_workerThread = (HANDLE)_beginthreadex(NULL, 0, WorkerThreadProc, NULL, 0, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're already on the platform thread, execute directly
|
// If we're already on the platform thread, execute directly
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ class ChannelManagerService : public FLTService
|
|||||||
public:
|
public:
|
||||||
ChannelManagerService();
|
ChannelManagerService();
|
||||||
|
|
||||||
void onMethodCalled(
|
virtual void onMethodCalled(
|
||||||
const std::string &method,
|
const std::string& method, const flutter::EncodableMap* arguments,
|
||||||
const flutter::EncodableMap *arguments,
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
override;
|
||||||
|
|
||||||
// Method handlers
|
// Method handlers
|
||||||
void setChannelListener(
|
void setChannelListener(
|
||||||
@@ -49,8 +49,7 @@ class ChannelManagerService : public FLTService
|
|||||||
const flutter::EncodableMap* arguments,
|
const flutter::EncodableMap* arguments,
|
||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_serviceName;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CHANNEL_MANAGER_SERVICE_H
|
#endif // CHANNEL_MANAGER_SERVICE_H
|
||||||
@@ -11,10 +11,10 @@ public:
|
|||||||
ConversationManagerService();
|
ConversationManagerService();
|
||||||
|
|
||||||
|
|
||||||
void onMethodCalled(
|
virtual void onMethodCalled(
|
||||||
const std::string& method,
|
const std::string& method, const flutter::EncodableMap* arguments,
|
||||||
const flutter::EncodableMap* arguments,
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
override;
|
||||||
|
|
||||||
// Method handlers
|
// Method handlers
|
||||||
void setConversationListener(
|
void setConversationListener(
|
||||||
@@ -75,8 +75,7 @@ public:
|
|||||||
const flutter::EncodableMap* arguments,
|
const flutter::EncodableMap* arguments,
|
||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_serviceName;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // CONVERSATION_MANAGER_SERVICE_H
|
#endif // CONVERSATION_MANAGER_SERVICE_H
|
||||||
@@ -12,10 +12,10 @@ class FriendshipManagerService : public FLTService
|
|||||||
public:
|
public:
|
||||||
FriendshipManagerService();
|
FriendshipManagerService();
|
||||||
|
|
||||||
void onMethodCalled(
|
virtual void onMethodCalled(
|
||||||
const std::string &method,
|
const std::string& method, const flutter::EncodableMap* arguments,
|
||||||
const flutter::EncodableMap *arguments,
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
override;
|
||||||
|
|
||||||
// Method handlers
|
// Method handlers
|
||||||
void setFriendListener(
|
void setFriendListener(
|
||||||
@@ -67,8 +67,6 @@ public:
|
|||||||
const flutter::EncodableMap* arguments,
|
const flutter::EncodableMap* arguments,
|
||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_serviceName;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FRIENDSHIP_MANAGER_SERVICE_H
|
#endif // FRIENDSHIP_MANAGER_SERVICE_H
|
||||||
@@ -12,10 +12,10 @@ class GroupManagerService : public FLTService
|
|||||||
public:
|
public:
|
||||||
GroupManagerService();
|
GroupManagerService();
|
||||||
|
|
||||||
void onMethodCalled(
|
virtual void onMethodCalled(
|
||||||
const std::string &method,
|
const std::string& method, const flutter::EncodableMap* arguments,
|
||||||
const flutter::EncodableMap *arguments,
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
override;
|
||||||
|
|
||||||
// Method handlers
|
// Method handlers
|
||||||
void setGroupListener(
|
void setGroupListener(
|
||||||
@@ -100,8 +100,7 @@ public:
|
|||||||
const flutter::EncodableMap* arguments,
|
const flutter::EncodableMap* arguments,
|
||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_serviceName;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // GROUP_MANAGER_SERVICE_H
|
#endif // GROUP_MANAGER_SERVICE_H
|
||||||
@@ -10,10 +10,10 @@ class MessageManagerService : public FLTService {
|
|||||||
public:
|
public:
|
||||||
MessageManagerService();
|
MessageManagerService();
|
||||||
|
|
||||||
void onMethodCalled(
|
virtual void onMethodCalled(
|
||||||
const std::string& method,
|
const std::string& method, const flutter::EncodableMap* arguments,
|
||||||
const flutter::EncodableMap* arguments,
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
override;
|
||||||
|
|
||||||
// Method handlers
|
// Method handlers
|
||||||
void setAdvancedMsgListener(
|
void setAdvancedMsgListener(
|
||||||
@@ -152,8 +152,7 @@ public:
|
|||||||
const flutter::EncodableMap* arguments,
|
const flutter::EncodableMap* arguments,
|
||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_serviceName;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MESSAGE_MANAGER_SERVICE_H
|
#endif // MESSAGE_MANAGER_SERVICE_H
|
||||||
@@ -15,21 +15,29 @@ void UserManagerService::onMethodCalled(
|
|||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result) {
|
||||||
if (method == "setUserListener") {
|
if (method == "setUserListener") {
|
||||||
setUserListener(arguments, result);
|
setUserListener(arguments, result);
|
||||||
} else if (method == "getUsersInfo") {
|
}
|
||||||
|
else if (method == "getUsersInfo") {
|
||||||
getUsersInfo(arguments, result);
|
getUsersInfo(arguments, result);
|
||||||
} else if (method == "setSelfInfo") {
|
}
|
||||||
|
else if (method == "setSelfInfo") {
|
||||||
setSelfInfo(arguments, result);
|
setSelfInfo(arguments, result);
|
||||||
} else if (method == "getSelfUserInfo") {
|
}
|
||||||
|
else if (method == "getSelfUserInfo") {
|
||||||
getSelfUserInfo(arguments, result);
|
getSelfUserInfo(arguments, result);
|
||||||
} else if (method == "subscribeUsersStatus") {
|
}
|
||||||
|
else if (method == "subscribeUsersStatus") {
|
||||||
subscribeUsersStatus(arguments, result);
|
subscribeUsersStatus(arguments, result);
|
||||||
} else if (method == "unsubscribeUsersStatus") {
|
}
|
||||||
|
else if (method == "unsubscribeUsersStatus") {
|
||||||
unsubscribeUsersStatus(arguments, result);
|
unsubscribeUsersStatus(arguments, result);
|
||||||
} else if (method == "getSubscribeUsersStatus") {
|
}
|
||||||
|
else if (method == "getSubscribeUsersStatus") {
|
||||||
getSubscribeUsersStatus(arguments, result);
|
getSubscribeUsersStatus(arguments, result);
|
||||||
} else if (method == "getUserStatus") {
|
}
|
||||||
|
else if (method == "getUserStatus") {
|
||||||
getUserStatus(arguments, result);
|
getUserStatus(arguments, result);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
result->NotImplemented();
|
result->NotImplemented();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,7 +48,8 @@ void UserManagerService::setUserListener(
|
|||||||
if (arguments) {
|
if (arguments) {
|
||||||
set_user_listener(NewUserListenCallBack());
|
set_user_listener(NewUserListenCallBack());
|
||||||
result->Success(flutter::EncodableValue());
|
result->Success(flutter::EncodableValue());
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,7 +64,8 @@ void UserManagerService::getUsersInfo(
|
|||||||
char* userIDList_cs = const_cast<char*>(userIDList.c_str());
|
char* userIDList_cs = const_cast<char*>(userIDList.c_str());
|
||||||
|
|
||||||
get_users_info(NewBaseCallBack(result), operationID_cs, userIDList_cs);
|
get_users_info(NewBaseCallBack(result), operationID_cs, userIDList_cs);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,7 +80,8 @@ void UserManagerService::setSelfInfo(
|
|||||||
char* userInfo_cs = const_cast<char*>(userInfo.c_str());
|
char* userInfo_cs = const_cast<char*>(userInfo.c_str());
|
||||||
|
|
||||||
set_self_info(NewBaseCallBack(result), operationID_cs, userInfo_cs);
|
set_self_info(NewBaseCallBack(result), operationID_cs, userInfo_cs);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -83,7 +94,8 @@ void UserManagerService::getSelfUserInfo(
|
|||||||
char* operationID_cs = const_cast<char*>(operationID.c_str());
|
char* operationID_cs = const_cast<char*>(operationID.c_str());
|
||||||
|
|
||||||
get_self_user_info(NewBaseCallBack(result), operationID_cs);
|
get_self_user_info(NewBaseCallBack(result), operationID_cs);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -98,7 +110,8 @@ void UserManagerService::subscribeUsersStatus(
|
|||||||
char* userIDs_cs = const_cast<char*>(userIDs.c_str());
|
char* userIDs_cs = const_cast<char*>(userIDs.c_str());
|
||||||
|
|
||||||
subscribe_users_status(NewBaseCallBack(result), operationID_cs, userIDs_cs);
|
subscribe_users_status(NewBaseCallBack(result), operationID_cs, userIDs_cs);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -113,7 +126,8 @@ void UserManagerService::unsubscribeUsersStatus(
|
|||||||
char* userIDs_cs = const_cast<char*>(userIDs.c_str());
|
char* userIDs_cs = const_cast<char*>(userIDs.c_str());
|
||||||
|
|
||||||
unsubscribe_users_status(NewBaseCallBack(result), operationID_cs, userIDs_cs);
|
unsubscribe_users_status(NewBaseCallBack(result), operationID_cs, userIDs_cs);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +140,8 @@ void UserManagerService::getSubscribeUsersStatus(
|
|||||||
char* operationID_cs = const_cast<char*>(operationID.c_str());
|
char* operationID_cs = const_cast<char*>(operationID.c_str());
|
||||||
|
|
||||||
get_subscribe_users_status(NewBaseCallBack(result), operationID_cs);
|
get_subscribe_users_status(NewBaseCallBack(result), operationID_cs);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,7 +156,8 @@ void UserManagerService::getUserStatus(
|
|||||||
char* userIDs_cs = const_cast<char*>(userIDs.c_str());
|
char* userIDs_cs = const_cast<char*>(userIDs.c_str());
|
||||||
|
|
||||||
get_user_status(NewBaseCallBack(result), operationID_cs, userIDs_cs);
|
get_user_status(NewBaseCallBack(result), operationID_cs, userIDs_cs);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
result->Error("INVALID_ARGUMENT", "Arguments cannot be null");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ class UserManagerService : public FLTService {
|
|||||||
public:
|
public:
|
||||||
UserManagerService();
|
UserManagerService();
|
||||||
|
|
||||||
void onMethodCalled(
|
virtual void onMethodCalled(
|
||||||
const std::string& method,
|
const std::string& method, const flutter::EncodableMap* arguments,
|
||||||
const flutter::EncodableMap* arguments,
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result)
|
||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
override;
|
||||||
|
|
||||||
// Method handlers
|
// Method handlers
|
||||||
void setUserListener(
|
void setUserListener(
|
||||||
@@ -42,8 +42,7 @@ public:
|
|||||||
const flutter::EncodableMap* arguments,
|
const flutter::EncodableMap* arguments,
|
||||||
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
std::shared_ptr<flutter::MethodResult<flutter::EncodableValue>> result);
|
||||||
|
|
||||||
private:
|
|
||||||
std::string m_serviceName;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // USER_MANAGER_SERVICE_H
|
#endif // USER_MANAGER_SERVICE_H
|
||||||
Reference in New Issue
Block a user