| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- #pragma once
- #include <iostream>
- #include <list>
- #include "FsLinkInc.h"
- #include "OperationReactor.h"
- using namespace std;
-
- class CFsProxy;
- class VirtualChan;
- class Session
- {
- public:
- Session(CFsProxy* pParent, string Id);
- ~Session();
- // 属性接口
- string id(void) const { return m_Id; }
- bool isVoid(void) const { return m_ListChan.empty(); }
- std::string& recordFile() { return m_RecordFile; }
- std::string& ringTime() { return m_RingTime; }
- std::string& answerTime() { return m_AnswerTime; }
- int getActionId()const { return m_AtionId; }
- // 判断通道id是否属于当前会话
- bool isContainChanId(const std::string& chanId);
- // 操作接口
- void prepare(PCHAN_EVENT_NOTIFY pNotify);
- void onChanEvent(PCHAN_EVENT_NOTIFY pNotify);
- void onChanDtmf(PDTMF_NOTIFY pNotify);
- void onChanHold(PHOLD_NOTIFY pNotify);
- VirtualChan* getAssoChan(VirtualChan* pChan);
- VirtualChan* getAssoFinalChan(); // 最后一条通道
- VirtualChan* getAssoFinalChan(VirtualChan* pChan); // 最后一条通道
- private:
- VirtualChan* __getFirstChan();
- VirtualChan* __getChan(string ChanId);
- VirtualChan* __findChan(PCHAN_EVENT_NOTIFY pNotify);
- void __addChan(VirtualChan* pChan);
- void __delChan(VirtualChan* pChan);
- void __clearChan(void);
- void __notifySessionChanEvent(VirtualChan* pChanHost, PCHAN_EVENT_NOTIFY pNotify);
- void __notifyIncomingChanEvent(VirtualChan* pChanHost, PCHAN_EVENT_NOTIFY pNotify);
- void __notifyDbSaveChanEvent(VirtualChan* pChanHost, PCHAN_EVENT_NOTIFY pNotify); // 判断保存通话记录到数据库
- void __saveAutoCallDB(VirtualChan* pChanHost, PCHAN_EVENT_NOTIFY pNotify); // 保存自动外呼通话记录
- void __onChanFree(VirtualChan* pChan, PCHAN_EVENT_NOTIFY pNotify);
- void __onPlayAgentNo(VirtualChan* pChan, PCHAN_EVENT_NOTIFY pNotify);
- void __onRecord(VirtualChan* pChan, PCHAN_EVENT_NOTIFY pNotify);
- void __createFileName(VirtualChan* pChan);
- void __onLineTalking(VirtualChan* pChan);
- private:
- CFsProxy* m_pParent;
- string m_Id;
- list<VirtualChan*> m_ListChan;
- std::mutex m_ChanLock;
- std::string m_RingTime; // 被叫振铃时间
- std::string m_AnswerTime; // 被叫应答时间
- bool m_IsAnswer; // 是否接听
- volatile bool m_IsSaveDb; // 是否更新数据库,一通电话会产生两次挂机事件,依据第一次收到的挂机事件保存,第二次收到后不保存
- volatile int m_AtionId;// 默认0,成功接听一通后+1
- std::string m_RecordFile; // 录音路径
- };
|