NetReceiveCStoreResponse Example for C++ 6.0 and later

void CDicomNetSink::OnNetReceiveCStoreResponse(long hNet, short nPresentationID, short nMessageID, LPCTSTR pszClass, LPCTSTR pszInstance, long nStatus) 
{
   //In this example, a C-Store Response is received.
   //Depending on the source of the message, several actions can take place.
   //See comments below for specific details.
   //
   //In this example:
   //1. m_LEADRasterView1, m_LEADRasterView2 are LEAD ActiveX Raster View (CLEADRasterView)
   // 
   //2. m_pLEADDicomNet is LEAD DicomNet COM object (ILEADDicomNet *m_pLEADDicomNet)
   //
   //3. m_nClientOrServer:  can be (STATUS_NONE, STATUS_SERVER, STATUS_CLIENT)
   //                       identifieds the LMyDicomNet object as a server or a client
   //4. m_nDataCommand:     can be (COMMAND_C_MOVE,COMMAND_C_GET) 
   //                       set so the server knows how a C-Store Response was generated
   //
   //5. A connection exists between client and server
   //6. An association exists between the client and server

   CString strMsg;   
   _bstr_t strPeerAddress = m_pDlg->m_pLEADDicomNet->GetPeerAddress (hNet);
   strMsg.Format("*** OnNetReceiveCStoreResponse ***\nPeer[%s]\nnPresentationID[%d]\nnMessageID[%d]\npszClass[%s]\npszInstance[%s]\nnStatus[%d]", 
      (char *)strPeerAddress,
      nPresentationID, 
      nMessageID, 
      pszClass,
      pszInstance,
      nStatus);
   
   //If I am a server, I receive this message from
   //
   //  1.Client sends C-Get
   //    I send SendCStoreRequest
   //    Clientsends SendCStoreResponse
   //
   //... or
   //
   //  2.Client sends C-Move
   //    I send SendCStoreRequest
   //    Clientsends SendCStoreResponse
   
   // m_nClientOrServer is a member variable that identifieds whether I am a client or server
   if (m_pDlg->m_nClientOrServer == STATUS_SERVER)
   {

      //m_nDataCommand is a member variable that is set so the server 
      //knows how a C-Store Response was generated
      //m_nDataCommand can be:
      //    COMMAND_C_MOVE
      //    COMMAND_C_GET

      switch (m_pDlg->m_nDataCommand)
      {
      case COMMAND_C_GET:
         strMsg = strMsg + "SendCGetResponse\n";
         m_pDlg->m_pLEADDicomNet->SendCGetResponse ( 
            hNet,
            nPresentationID, 
            nMessageID,
            pszClass, 
            COMMAND_STATUS_SUCCESS,    //L_UINT16 nStatus
            0,                         //L_UINT16 nRemaining
            1,                         //L_UINT16 nCompleted
            0,                         //L_UINT16 nFailed
            0,                         //L_UINT16 nWarning
            0                          //LDicomDS1 *pDS
            );
         break;
         
      case COMMAND_C_MOVE:
         strMsg = strMsg + "SendCMoveResponse\n";
         m_pDlg->m_pLEADDicomNet->SendCMoveResponse(  
            hNet,
            nPresentationID, 
            nMessageID,
            pszClass, 
            COMMAND_STATUS_SUCCESS,    //L_UINT16 nStatus
            0,                         //L_UINT16 nRemaining
            1,                         //L_UINT16 nCompleted
            0,                         //L_UINT16 nFailed
            0,                         //L_UINT16 nWarning
            0                          //LDicomDS1 *pDS
            );
         break;
      };   
   }
   m_pDlg->m_nDataCommand = 0;
   AfxMessageBox(strMsg);