Hi to all! My application is a GUI agent, which communicate with daemon through the unix domain socket, wrapped in CFSocket.... So there are main loop and added CFRunLoop source. Daemon sends statuses and agent shows it with a progress indicator. When there are any data on socket, callback function begin to work and at this time I have to immediately show the new window with progress indicator and increase counter.
//this function initiate the runloop for listening socket
- (int) AcceptDaemonConnection:(ConnectionRef)conn
{
int err = 0;
conn->fSockCF = CFSocketCreateWithNative(NULL,
(CFSocketNativeHandle) conn->fSockFD,
kCFSocketAcceptCallBack,
ConnectionGotData,
NULL);
if (conn->fSockCF == NULL)
err = EINVAL;
if (err == 0)
{
conn->fRunLoopSource = CFSocketCreateRunLoopSource(NULL, conn->fSockCF, 0);
if (conn->fRunLoopSource == NULL)
err = EINVAL;
else CFRunLoopAddSource(CFRunLoopGetCurrent(),
conn->fRunLoopSource,
kCFRunLoopDefaultMode);
CFRelease(conn->fRunLoopSource);
}
return err;
}
// callback function
void ConnectionGotData(CFSocketRef s,
CFSocketCallBackType type,
CFDataRef address,
const void * data,
void * info)
{
#pragma unused(s)
#pragma unused(address)
#pragma unused(info)
assert(type == kCFSocketAcceptCallBack);
assert( (int *) data != NULL );
assert( (*(int *) data) != -1 );
TStatusUpdate status;
int nativeSocket = *(int *) data;
status = [agg AcceptPacket:nativeSocket]; // [stWindow InitNewWindow] inside
[agg SendUpdateStatus:status.percent];
}
AcceptPacket function receives packet from the socket and trying to show new window with progress indicator. Corresponding function is called, but nothing happens... I think, that I have to make work the main application loop with interrupting CFSocket loop... Or send a notification? No idea....