| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- /*************************************************************************
- 【文件名】 FsProxy.h
- 【功能模块和目的】 FS代理控制类头文件
- 【开发者及日期】 郑石诺 2016/06/21
- 【版本】 V1.0.0
- 【版权信息】 Copyright (C)2016 河南华谊网络科技有限公司
- 【更改记录】
- *************************************************************************/
- #pragma once
- #include "EslGateway.h"
- #include "IEslEventHandler.h"
- #include "CallStringMaker.h"
- class CChanExten;
- class CChanTrunk;
- class CVirtualChan;
- class CSession;
- /*************************************************************************
- 【类名】 CFsProxy
- 【功能】
- 【接口说明】 FS代理控制类
- 【开发者及日期】 郑石诺 2016/06/21
- 【版本】 V1.0.0
- 【版权信息】 Copyright (C)2016 河南华谊网络科技有限公司
- 【更改记录】
- *************************************************************************/
- class CFsProxy
- {
- SINGLETON_DECLARE(CFsProxy)
- public:
- ~CFsProxy(void);
- bool init(IEslEventHandler* pEventHandler);
- void release(void);
- // 事件处理
- void onChanRegist(DEV_RES_TYPE ChanType, UINT ChanNo, CHAN_LOGIC_STATE ChanState);
- void onExtenDestroy(UINT ExtenNo);
- void onExtenDirectOp(DEV_OP OpType, CVirtualChan* pHostChan, PCHAN_EVENT_NOTIFY pNotify);
- void onChanStateUpdate(LONG OpInstance, CVirtualChan* pChan);
- void onChanPoor(CSession* pSession, PCHAN_EVENT_NOTIFY pNotify);
- void onTrunkCallIn(CChanTrunk* pTrunk);
- // ESL事件
- void onEslDisconnect(void);
- void onEslExtenReg(UINT ExtenNo);
- void onEslExtenUnreg(UINT ExtenNo);
- void onEslEvtBgJobDone(PBG_JOB_NOTIFY pNotify);
- void onEslEvtChannel(PCHAN_EVENT_NOTIFY pNotify);
- void onEslEvtDtmf(PDTMF_NOTIFY pNotify);
- void onEslEvtHold(PHOLD_NOTIFY pNotify);
- // 功能接口
- CChanExten* getExten(UINT ExtenNo);
- CChanTrunk* getTrunk(UINT TrunkNo);
- void delChan(CVirtualChan* pChan);
- CChanTrunk* getFreeTrunk(void);
- CVirtualChan* getAssoChanInSession(CVirtualChan* pChan);
- CVirtualChan* getBusyChan(LPCTSTR ChanId);
- void regBusyChan(CVirtualChan* pChan);
- void unregBusyChan(CVirtualChan* pChan);
- // 语音操作接口
- bool ExtenCall(LONG JobId, CVirtualChan* pChan, LPCTSTR CallerNum, LPCTSTR CalleeNum);
- bool PredictionCall(LONG JobId, CString CallerNum, CString CalleeNum);
- bool answer(LONG JobId, CVirtualChan* pChan);
- bool kill(LONG JobId, CVirtualChan* pChan);
- bool consult(LONG JobId, CVirtualChan* pChan, CString DestNum);
- bool insert(LONG JobId, CVirtualChan* pChan, LPCTSTR DestSessionId);
- bool intercept(LONG JobId, CVirtualChan* pChan, LPCTSTR DestChanId);
- bool listen(LONG JobId, CVirtualChan* pChan, LPCTSTR DestChanId);
- bool meeting(LONG JobId, CString CallerNum, CString DestNum, LPCTSTR MeetingId);
- std::string EslCommand(std::string strFsIp, int FsPort, std::string strName, std::string strPsWd, std::string strCommand);
- bool muteOn(LONG JobId, CVirtualChan* pChan);
- bool muteOff(LONG JobId, CVirtualChan* pChan);
- bool holdon(LONG JobId, CVirtualChan* pChan);
- bool takeBack(LONG JobId, CVirtualChan* pChan);
- bool record(LONG JobId, CVirtualChan* pChan, LPCTSTR RcdFile);
- bool transfer(LONG JobId, CVirtualChan* pChan, LPCTSTR DestNum);
- bool transfer2Context(LONG JobId, LPCTSTR DestChanId, LPCTSTR Exten, LPCTSTR Context, bool BothSide = false);
- // IVR任务
- bool cancel(CChanTrunk* pChan);
- bool hangup(CChanTrunk* pChan);
- bool leaveWord(CChanTrunk* pChan, LPCTSTR FileName, UINT LimitTime, TCHAR FinishKey);
- bool playAndDtmf(CChanTrunk* pChan, PlayVoiceContent* pPlayContent);
- bool bridge(CChanTrunk* pChan, CString CallerNum, CString CalleeNum);
- private:
- CFsProxy(void);
- UINT __transLogicState2CtiState(DEV_RES_TYPE ChanType, CHAN_LOGIC_STATE State);
- void __addExten(UINT ExtenNo);
- void __delExten(UINT ExtenNo);
- void __freeExten(void);
- void __initTrunkChan(void);
- void __freeTrunkChan(void);
- CSession* __getSession(LPCTSTR SessionId);
- CSession* __getSession(PCHAN_EVENT_NOTIFY pNotify, bool NewWhenNull = false);
- void __delSession(LPCTSTR SessionId);
- void __freeSession(void);
- bool __kill(LONG JobId, LPCTSTR ChanId);
- private:
- CEslGateway m_Gateway;
- CCallStringMaker m_CallStringMaker;
- CArray<CChanTrunk*, CChanTrunk*> m_ArrayTrunk; // 中继数组
- CMap<UINT, UINT, CChanExten*, CChanExten*> m_MapChanExt; // 分机表
- CMap<CString, LPCTSTR, CVirtualChan*, CVirtualChan*> m_MapBusyChan; // 忙通道表
- CMap<CString, LPCTSTR, CSession*, CSession*> m_MapSession; // 会话表
- IEslEventHandler* m_pEventHandler;
- esl_handle_t m_EslHandle;
- };
|