Closes a service object on a server.
DWORD ctaDetachObject ( unsigned objhd)
Argument |
Description |
objhd |
Object handle returned by ctaAttachObject. |
Return value |
Description |
SUCCESS |
|
CTA_INVALID_HANDLE |
The specified objhd is not valid. |
CTAERR_NOT_IMPLEMENTED |
This function is not available in the execution mode associated with the specified context. |
CTAERR_NOT_INITIALIZED |
Natural Access is not initialized. Call ctaInitialize first. |
ctaDetachObject disconnects the application from the object handle that ctaAttachObject obtained.
int DemoAttachDetach(char* contextname, char* objname)
{
DWORD ret;
CTAQUEUEHD ctaqueuehd;
char *mgrlist[] = { "ADIMGR", "ADIMGR", "VCEMGR", "SWIMGR"};
ret = ctaCreateQueue( mgrlist,
sizeof(mgrlist)/sizeof(mgrlist[0]),
&ctaqueuehd);
if ( ret != SUCCESS )
return ret;
// Attach to existing server context
CTAHD ctahd;
ret = ctaAttachContext(ctaqueuehd,0,contextname,&ctahd);
if ( ret != SUCCESS )
return ret;
// Attach to existing call
unsigned callhd;
ret = ctaAttachObject(&ctahd,objname,&callhd);
if ( ret != SUCCESS )
return ret;
printf("Attached to call 0x%08X\n",callhd);
// Get call status
NCC_CALL_STATUS info;
ret = nccGetCallStatus( callhd, &info, sizeof( NCC_CALL_STATUS ) );
if ( ret != SUCCESS )
return ret;
printf("Called number: %s\n",info.calledaddr );
// Detach from the call
ret = ctaDetachObject(callhd);
if ( ret != SUCCESS )
return ret;
printf("Detached\n");
return SUCCESS;
}