DSC Tech Library
CTI Universal Softphone API Library
SAMPLE MESSAGE HANDLER
LRESULT
CTestrspapiDlg::OnNMQMessage(WPARAM wParam, LPARAM lParam)
{
static char l_Buffer[sizeof(struct RspApiResponse)];
static struct RspApiResponse *
mainResponse =
(RspApiResponse *)&l_Buffer;
static struct RspApiLoginResponse * loginResponse =
(RspApiLoginResponse *)mainResponse->value;
static struct RspApiInboundResponse *
inboundResponse =
(RspApiInboundResponse
*)mainResponse->value;
BOOL
m_Success;
BOOL
m_IsLoggedIn;
BOOL
m_InvalidMessage;
BOOL
m_Transferred;
CString m_Ani;
CString m_DNIS;
int
m_RecordNumber; // user defined usage
CString m_Campaign;
CString errorOut;
while(RSPMessage(l_Buffer,0)){
m_InvalidMessage = FALSE;
switch(RSPDecode(l_Buffer, mainResponse)){
case RSP_RT_PING:
{
errorOut.Format("Type:
PING");
}
break;
case RSP_RT_LOGIN:
{
errorOut.Format("Type: LOGIN,
Error: %d, ”
”incamp: %d, relog:
%d",
mainResponse->error,
loginResponse->incamp,
loginResponse->relog);
if(mainResponse->error ==
RSPAPI_SUCCESS){
m_Success = TRUE;
m_IsLoggedIn = RSPIsLoggedIn();
if((m_IsLoggedIn =
RSPIsLoggedIn())){
w_LoginButton->EnableWindow(FALSE);
w_LogoutButton->EnableWindow(TRUE);
w_BadLoginButton1->EnableWindow(FALSE);
w_BadLoginButton2->EnableWindow(FALSE);
w_CancelButton->EnableWindow(FALSE);
}else{
w_LoginButton->EnableWindow(TRUE);
w_LogoutButton->EnableWindow(FALSE);
w_BadLoginButton1->EnableWindow(TRUE);
w_BadLoginButton2->EnableWindow(TRUE);
w_CancelButton->EnableWindow(TRUE);
}
}else
m_Success = FALSE;
}
break;
case RSP_RT_AVAILABLE:
{
errorOut.Format("Type: AVAILABLE,
Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUND){
}else /* if(mainResponse->error
== RSPAPI_ERROR)*/{
}
}
break;
case RSP_RT_UNAVAILABLE:
{
errorOut.Format("Type:
UNAVAILABLE, Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUND){
}else if(mainResponse->error ==
RSPAPI_ERROR){
}
}
break;
case RSP_RT_CONFERENCE:
{
errorOut.Format("Type:
CONFERENCE, Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUND){
}else if(mainResponse->error ==
RSPAPI_ERROR){
}
}
break;
case RSP_RT_DIALDIGITS:
{
errorOut.Format("Type:
DIALDIGITS, Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUND){
}else if(mainResponse->error ==
RSPAPI_ERR_NOCALL){
}else if(mainResponse->error ==
RSPAPI_ERROR){
}
}
break;
case RSP_RT_MAKECALL:
{
errorOut.Format("Type:
MAKECALL, Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUND){
}else if(mainResponse->error ==
RSPAPI_ERROR){
}
}
break;
case RSP_RT_DISCONNECTCALL:
{
errorOut.Format("Type:
DISCONNECTCALL, Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUND){
}else if(mainResponse->error == RSPAPI_ERROR){
}
}
break;
case RSP_RT_ONHOLD:
{
errorOut.Format("Type: ONHOLD,
Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUND){
}else if(mainResponse->error ==
RSPAPI_ERROR){
}
}
break;
case RSP_RT_MONITOR:
{
errorOut.Format("Type: MONITOR,
Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUNDTARGET){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUND){
}else if(mainResponse->error ==
RSPAPI_ERROR){
}
}
break;
case RSP_RT_PAMALARM:
{
errorOut.Format("Type:
PAMALARM, Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUND){
}else if(mainResponse->error ==
RSPAPI_ERR_INVALID){
}
}
break;
case RSP_RT_RECONNECT:
{
errorOut.Format("Type:
RECONNECT, Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUND){
}else if(mainResponse->error ==
RSPAPI_ERROR){
}
}
break;
case RSP_RT_RECORDON:
{
errorOut.Format("Type:
RECORDON, Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUND){
}else if(mainResponse->error ==
RSPAPI_ERROR){
}
}
break;
case RSP_RT_RECORDOFF:
{
errorOut.Format("Type:
RECORDOFF, Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUND){
}else if(mainResponse->error ==
RSPAPI_ERROR){
}
}
break;
case RSP_RT_TRANSFER:
{
errorOut.Format("Type:
TRANSFER, Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUNDTARGET){
}else if(mainResponse->error == RSPAPI_ERR_NOTFOUND){
}else if(mainResponse->error ==
RSPAPI_ERROR){
}
}
break;
case RSP_RT_CANCELTRANSFER:
{
errorOut.Format("Type:
CANCELTRANSFER, Error: %d",
mainResponse->error);
if(mainResponse->error ==
RSPAPI_SUCCESS){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUNDTARGET){
}else if(mainResponse->error ==
RSPAPI_ERR_NOTFOUND){
}else if(mainResponse->error ==
RSPAPI_ERROR){
}
}
break;
case RSP_RT_SHUTDOWN:
{
// predictive campaign has been shut down
(list manager stopped)
errorOut.Format("Type:
SHUTDOWN");
}
break;
case RSP_RT_PAUSED:
{
// predictive campaign has been paused
errorOut.Format("Type:
PAUSED");
}
break;
case RSP_RT_ONCALL:
{
// connected to a call
errorOut.Format("Type:
CONNECTED INBOUND");
m_Transferred =
(inboundResponse->transferred == 1);
m_Ani = inboundResponse->ani;
m_DNIS = inboundResponse->dnis;
sscanf(inboundResponse->identifier,"%d",&m_RecordNumber);
m_Campaign =
inboundResponse->campaign;
}
break;
case RSP_RT_INVALID:
{
errorOut.Format("Type:
INVALID");
m_InvalidMessage = TRUE;
}
break;
default:
{
errorOut.Format("This should
never happen!");
m_InvalidMessage = TRUE;
}
break;
}
m_ErrorOut.SetWindowText(errorOut);
}
return 0;
}
|