SetHeartbeatTimeoutCallback
Top  Previous  Next

Description

Sets up a callback function which will be called when a client application connects to the virtual camera or disconnects from it.

[C++]
int
 SetHeartbeatTimeoutCallback(void* context, HeartbeatTimeoutCallback callback);

   
where HeartbeatTimoutCallback type is defined as

    typedef void (*HeartbeatTimeoutCallback)(void* context, bool connected);


Parameters
[C/C++]
 
[in] void* context  
Address of the context in which the callback function will be called.  
 
[in] HeartbeatTimeoutCallback callback  
Address of the callback function  
 
[in] bool connected  
TRUE when the client application connects to the virtual camera, FALSE when disconnects.  
 

Return Values


S_OK  
Success  
E_FAIL  
Failure  


Example


This fragment of an MFC code uses the HeartbeatTimeout callback to inform the virtual camera application about the connection/disconnection status of a remote client application.

   

void heartbeatTimeoutCallback(void* context, bool connected)  
{  
      return dlg->onHeartbeatTimeout(connected);  
}  

bool CGigemuDlg::onHeartbeatTimeout(bool connected)  
{  
    if(connected)  
         printf("External client connected to virtual camera\n");  
    else  
         printf("External client disconnected from virtual camera\n");  
        
  return true;  
}  

      bool
CGigemuDlg::OnInitDialog()
      {
      ....        
   static CGevCamera* m_pCamera;  
   m_pCamera = createCamera();  
      m_pCamera->SetHeartbeatTimeoutCallback(this, &::heartbeatTimeoutCallback);  
       ....  
}  
 

Remarks


The write callback function is called immediately after an external client applicatoin connects to the camera and starts sending the heartbeat to it. It is also called when GigESim detects the absense of the heartbeat which indicates that the client application is no longer connected to the virtual camera.

If you are using a callback function in the main thread of the simulation application, make sure that no lengthy processing is done in the body of the function as otherwise the connection to the remote client may become broken.