📄 form1.cs
字号:
{
if(nToneChResult == 1)
{
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_GET_1STDTMF", "SsmStopSendTone");
}
}
}
else
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_GET_1STDTMF", "SsmChkSendTone");
}
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_F_GET_DTMF", "SsmSendTone");
}
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_WAIT_HANGUP;
break;
case APP_USER_STATUS.USER_DIALOUT:
//detect whether it is dialing or not
nToneType = 0;
nToneChResult = SsmChkSendTone(nCh,ref nToneType);
if(nToneChResult != -1)
{
if(nToneChResult == 1)
{
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_DIALOUT", "SsmStopSendTone");
}
}
}
else
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_DIALOUT", "SsmChkSendTone");
}
//send E_TK_RELEASE
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_WAIT_HANGUP;
SendMessage(hwnd,WM_USER+(int)EventMsg.E_TK_RELEASE,(IntPtr) ChInfo[nCh].nLinkToCh,(IntPtr) nCh);
//close TX
if(ShDll.SsmStopTimer(ChInfo[nCh].nTimer) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_DIALOUT", "SsmStopTimer");
}
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_DIALOUT", "SsmSendTone");
}
break;
case APP_USER_STATUS.USER_F_GET_DTMF:
//close T4
if(ShDll.SsmStopTimer(ChInfo[nCh].nTimer) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_F_GET_DTMF", "SsmStopTimer");
}
nToneType = 0;
nToneChResult = SsmChkSendTone(nCh,ref nToneType);
if(nToneChResult != -1)
{
if(nToneChResult == 1)
{
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_F_GET_DTMF", "SsmStopSendTone");
}
}
}
else
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_F_GET_DTMF", "SsmChkSendTone");
}
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "USER_F_GET_DTMF", "SsmSendTone");
}
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_F_OPERATE;
break;
default:
//close TX
if(ShDll.SsmStopTimer(ChInfo[nCh].nTimer) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "default", "SsmStopTimer");
}
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_SYS_TIMEOUT", "default", "SsmSendTone");
}
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_WAIT_HANGUP;
break;
}
break;
/*+++++++++define station channel message+++++++++*/
case (int)EventMsg.E_US_SEIZURE:
if(APP_USER_STATUS.USER_IDLE == ChInfo[nCh].nStatus)
{
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_LOCAL_RING;
//send E_US_SEIZURE_ACK_IDLE
SendMessage(hwnd,WM_USER+(int)EventMsg.E_US_SEIZURE_ACK_IDLE, (IntPtr)lParam, (IntPtr)nCh);
//send ringing tone
if(SsmStartRing(nCh) == -1)
{
ShowErrMsg("E_US_SEIZURE", "USER_IDLE", "SsmStartRing");
}
ChInfo[nCh].nLinkToCh = lParam;
//retrieve CallerId
if(ChInfo[ChInfo[nCh].nLinkToCh].nChType == 0)
{
if(ShDll.SsmGetCallerId(ChInfo[nCh].nLinkToCh, ChInfo[nCh].szCallerId) == -1)
{
ShowErrMsg("E_US_SEIZURE", "USER_IDLE", "SsmGetCallerId");
}
}
else
{
ChInfo[nCh].szCallerId = ChInfo[ChInfo[nCh].nLinkToCh].szUserNum;
}
}
else
{
//send E_US_SEIZURE_ACK_BUSY
SendMessage(hwnd,WM_USER+(int)EventMsg.E_US_SEIZURE_ACK_BUSY, (IntPtr)lParam, (IntPtr)nCh);
}
break;
case (int)EventMsg.E_US_SEIZURE_ACK_IDLE: //it is detected that station channel is seizured successfully
switch(ChInfo[nCh].nStatus)
{
case APP_USER_STATUS.USER_REQ_USER:
//play ringback tone
if(SsmSendTone(nCh, 2) == -1)
{
ShowErrMsg("E_US_SEIZURE_ACK_IDLE", "USER_REQ_USER", "SsmSendTone");
}
//retrieve CalledId
ChInfo[nCh].szCalleeId = new StringBuilder (ChInfo[nCh].szPhoneNumBuf.ToString ());
ChInfo[nCh].nLinkToCh = lParam;
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_RING_BACK;
break;
case APP_USER_STATUS.USER_F_REQ_USER: //extension in call transfer is seized successfully
//play ringback tone
if(SsmSendTone(nCh, 2) == -1)
{
ShowErrMsg("E_US_SEIZURE_ACK_IDLE", "USER_F_REQ_USER", "SsmSendTone");
}
//retrieve CalledId
ChInfo[nCh].szCalleeId = new StringBuilder (ChInfo[nCh].szPhoneNumBuf.ToString ());
ChInfo[nCh].nLinkToCh = lParam;
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_F_RING_BACK;
break;
default:
break;
}
break;
case (int)EventMsg.E_US_SEIZURE_ACK_BUSY: //failed to seize designatedstation channel
switch(ChInfo[nCh].nStatus)
{
case APP_USER_STATUS.USER_REQ_USER:
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_US_SEIZURE_ACK_IDLE", "USER_REQ_USER", "SsmSendTone");
}
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_WAIT_HANGUP;
break;
case APP_USER_STATUS.USER_F_REQ_USER:
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_US_SEIZURE_ACK_IDLE", "USER_F_REQ_USER", "SsmSendTone");
}
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_F_OPERATE;
break;
default:
break;
}
break;
case (int)EventMsg.E_US_PICKUP:
//Called party go off-hook
switch(ChInfo[nCh].nStatus)
{
case APP_USER_STATUS.USER_RING_BACK:
//stop sending of rinback tone
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_US_PICKUP", "USER_RING_BACK", "SsmStopSendTone");
}
//build bus connection
if(ShDll.SsmTalkWith(nCh, ChInfo[nCh].nLinkToCh) == -1)
{
ShowErrMsg("E_US_PICKUP", "USER_RING_BACK", "SsmTalkWith");
}
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_TALKING;
break;
case APP_USER_STATUS.USER_F_RING_BACK:
//stop sending of ringback tone
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_US_PICKUP", "USER_F_RING_BACK", "SsmStopSendTone");
}
//build bus connection between ch1 and ch2
if(ShDll.SsmTalkWith(nCh, ChInfo[nCh].nLinkToCh) == -1)
{
ShowErrMsg("E_US_PICKUP", "USER_F_RING_BACK", "SsmTalkWith");
}
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_F_TALKING;
break;
}
break;
case (int)EventMsg.E_US_RELEASE:
//stop ringing
if(ShDll.SsmStopRing(nCh) == -1)
{
ShowErrMsg("E_US_RELEASE", "", "SsmStopRing");
}
ChInfo[nCh].nLinkToCh = -1;
ChInfo[nCh].bPressFlag = false;
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_IDLE;
ChInfo[nCh].szCallerId = new StringBuilder (NUM_LENGTH); //clear CalledId
break;
case (int)EventMsg.F_US_SEIZURE:
if(APP_USER_STATUS.USER_IDLE == ChInfo[nCh].nStatus)
{
//send ringing
if(SsmStartRing(nCh) == -1)
{
ShowErrMsg("F_US_SEIZURE", "USER_IDLE", "SsmStartRing");
}
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_LOCAL_RING;
ChInfo[nCh].nLinkToCh = lParam;
ChInfo[nCh].bPressFlag = true;
ChInfo[nCh].szCallerId = ChInfo[ChInfo[nCh].nLinkToCh].szUserNum;
SendMessage(hwnd,WM_USER+(int)EventMsg.E_US_SEIZURE_ACK_IDLE, (IntPtr)lParam, (IntPtr)nCh);
}
else
{
SendMessage(hwnd,WM_USER+(int)EventMsg.E_US_SEIZURE_ACK_BUSY, (IntPtr)lParam, (IntPtr)nCh);
}
break;
/*+++++++++define analog trunk channel message+++++++++*/
case (int)EventMsg.E_TK_SEIZURE_TK_ACK_IDLE: //trunk channel is seized successfully
//send dial tone
if(SsmSendTone(nCh, 0) == -1)
{
ShowErrMsg("E_TK_SEIZURE_TK_ACK_IDLE", "", "SsmSendTone");
}
//start T3:18 seconds
if( (ChInfo[nCh].nTimer = ShDll.SsmStartTimer(18000, 1)) == -1)
{
ShowErrMsg("E_TK_SEIZURE_TK_ACK_IDLE", "", "SsmStartTimer");
}
ChInfo[nCh].nLinkToCh =lParam;
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_DIALOUT;
break;
case (int)EventMsg.E_TK_SEIZURE_TK_ACK_BUSY: //failed to seize designated trunk channel
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_TK_SEIZURE_TK_ACK_BUSY", "", "SsmSendTone");
}
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_WAIT_HANGUP;
break;
case (int)EventMsg.E_TK_DIAL_OK:
//close T3
if(ShDll.SsmStopTimer(ChInfo[nCh].nTimer) == -1)
{
ShowErrMsg("E_TK_DIAL_OK", "", "SsmStopTimer");
}
//play ringback tone
if(SsmSendTone(nCh, 2) == -1)
{
ShowErrMsg("E_TK_DIAL_OK", "", "SsmSendTone");
}
//retrieve CalledId
if (SsmGetDtmfStr(nCh,ChInfo[nCh].szCalleeId) == -1)
{
ShowErrMsg("E_TK_DIAL_OK", "", "SsmGetDtmfStr");
}
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_WAIT_REMOTE_PICKUP;
break;
case (int)EventMsg.E_TK_DIAL_FAIL:
//detect whether dial tone is present
nToneType = 0;
nToneChResult = SsmChkSendTone(nCh,ref nToneType);
if(nToneChResult != -1)
{
if(nToneChResult == 1)
{
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_TK_DIAL_FAIL", "", "SsmStopSendTone");
}
}
}
else
{
ShowErrMsg("E_TK_DIAL_FAIL", "", "SsmChkSendTone");
}
//close T3
if(ShDll.SsmStopTimer(ChInfo[nCh].nTimer) == -1)
{
ShowErrMsg("E_TK_DIAL_FAIL", "", "SsmStopTimer");
}
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_TK_DIAL_FAIL", "", "SsmSendTone");
}
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_WAIT_HANGUP;
break;
case (int)EventMsg.E_TK_REMOTE_NOANSWER: //trunk channel does not answer
//stop sending of ringback tone
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_TK_REMOTE_NOANSWER", "", "SsmStopSendTone");
}
//play busy tone
if(SsmSendTone(nCh, 1) == -1)
{
ShowErrMsg("E_TK_REMOTE_NOANSWER", "", "SsmSendTone");
}
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_WAIT_HANGUP;
break;
case (int)EventMsg.E_TK_REMOTE_PICKUP: //remote end go off-hook
switch(ChInfo[nCh].nStatus)
{
case APP_USER_STATUS.USER_DIALOUT:
//close T3
if(ShDll.SsmStopTimer(ChInfo[nCh].nTimer) == -1)
{
ShowErrMsg("E_TK_REMOTE_PICKUP", "USER_DIALOUT", "SsmStopTimer");
}
//build bus connection between station and trunk channel
if(ShDll.SsmTalkWith(nCh, ChInfo[nCh].nLinkToCh) == -1)
{
ShowErrMsg("E_TK_REMOTE_PICKUP", "USER_DIALOUT", "SsmTalkWith");
}
ChInfo[nCh].nStatus = APP_USER_STATUS.USER_TALKING;
break;
case APP_USER_STATUS.USER_WAIT_REMOTE_PICKUP:
//stop sending of ringback tone
if(SsmStopSendTone(nCh) == -1)
{
ShowErrMsg("E_TK_REMOTE_NOANSWER", "", "SsmStopSendTone");
}
//build bus connection
if(ShDll.SsmTalkWith(nCh, ChInfo[nCh].nLinkToCh) == -1)
{
ShowErrMsg("E_TK_REMOTE_PICKUP", "USER_WAIT_REMOTE_PICKUP", "SsmTalkWith");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -