main 0.0.29
cpdl 2 months ago
parent 1af1ecfbb9
commit 114980dab0
  1. 27
      example/lib/main.dart
  2. 20
      windows/src/common/ThreadUtil.cpp

@ -23,27 +23,26 @@ class _MyAppState extends State<MyApp> {
super.initState();
OpenIM.iMManager
.initSDK(
platformID: 2,
platformID: 3,
apiAddr: 'http://192.168.77.135:10002',
wsAddr: 'ws://192.168.77.135:10001',
dataDir: './',
listener: OnConnectListener())
.then((value) {
print('SDK initialized successfully');
OpenIM.iMManager.userManager.setUserListener(OnUserListener());
.then((value) {});
OpenIM.iMManager.userManager.setUserListener(OnUserListener());
OpenIM.iMManager
.login(
userID: "3e8b8fb2ecd8414db50838d9f7bcb19d",
token:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOiIzZThiOGZiMmVjZDg0MTRkYjUwODM4ZDlmN2JjYjE5ZCIsIlBsYXRmb3JtSUQiOjIsImV4cCI6MTc1Mzc1MTYyNywiaWF0IjoxNzQ1OTc1NjIyfQ.S-CxfETXYyLFe2VqStwbrVCRcB5j2T2qi-52y1L-3OI")
OpenIM.iMManager
.login(
userID: "8bfe13b5eac44e87963652abb91d80d2",
token:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySUQiOiI4YmZlMTNiNWVhYzQ0ZTg3OTYzNjUyYWJiOTFkODBkMiIsIlBsYXRmb3JtSUQiOjMsImV4cCI6MTc1NDM2NDkwNCwiaWF0IjoxNzQ2NTg4ODk5fQ.575xwR9lzJo1i5Te-Ul-99odONfxbzDXW0_2Kv3nFEE")
.then((value) {
OpenIM.iMManager.conversationManager
.getAllConversationList()
.then((value) {
print('Login successful');
}).catchError((error) {
print('Login failed: $error');
print('Get all conversation list successful');
});
});
}).catchError((error) {});
}
@override

@ -14,13 +14,6 @@ namespace ThreadUtil {
static std::condition_variable g_queueCondition;
static bool g_initialized = false;
static HANDLE g_workerThread = NULL;
// Function to initialize the platform thread ID
void InitializePlatformThreadId() {
g_platformThreadId = GetCurrentThreadId();
g_initialized = true;
}
// Worker thread function
unsigned __stdcall WorkerThreadProc(void* param) {
while (true) {
@ -39,6 +32,16 @@ namespace ThreadUtil {
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
void RunOnPlatformThread(std::function<void()> callback) {
@ -46,8 +49,7 @@ namespace ThreadUtil {
if (!g_initialized) {
InitializePlatformThreadId();
// Create worker thread
g_workerThread = (HANDLE)_beginthreadex(NULL, 0, WorkerThreadProc, NULL, 0, NULL);
}
// If we're already on the platform thread, execute directly

Loading…
Cancel
Save