I am building a cross-platform application (Win & Mac) to interact with the local Skype client via the Skype Desktop API. The application's UI is written in JS but the module that communicates with the Skype client is a C++ NodeJS addon. The problem I'm facing is that on Mac, the Skype framework sends all notifications from Skype to the main thread so I would have to start the runLoop on the main thread in order to receive them. But this is not possible, as the main thread in my application cannot be blocked as it is the NodeJS UI thread.
I am wondering if there is a way to control where the notifications are sent from the Skype framework.
I have created a simple XCode project that illustrates how the framework is called: https://github.com/saw666/MacSkypeWrapper
My goal would be to receive the notifications on the secondary thread that I'm creating, rather than on the main one. Here is the main.mm file
void func1()
{
cout << "I'm Thread\n";
CPPSkypeAPIWrapper::GetInstance()->SkypeConnect();
@autoreleasepool{
NSDate* futureDate = [NSDate dateWithTimeIntervalSinceNow:5];
NSTimer* myTimer = [[NSTimer alloc] initWithFireDate:futureDate interval:1 target:myTimer selector:@selector(onTick) userInfo:nil repeats:NO];
NSRunLoop* myLoop = [NSRunLoop currentRunLoop];
[myLoop addTimer:myTimer forMode:NSDefaultRunLoopMode];
[myLoop run];
}
}
int main(int argc, const char * argv[])
{
cout << "I'm Main\n";
/* If you un-comment this the notification from Skype come to the main thread and the runLoop goes forever*/
/*CPPSkypeAPIWrapper::GetInstance()->SkypeConnect();
@autoreleasepool{
NSRunLoop* myLoop = [NSRunLoop currentRunLoop];
[myLoop run];
}*/
thread t1(func1);
t1.join();
return 0;
}
via saw66
No comments:
Post a Comment