| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- #include "StdAfx.h"
- #include "PduEventHost.h"
- #include "NetRepInterface.h"
- CPduEventHost::CPduEventHost(void)
- {
- }
-
- CPduEventHost::~CPduEventHost(void)
- {
- }
- /*****************************************************************
- **【函数名称】 RegLinkProc
- **【函数功能】 订阅连接管理事件
- **【参数】 a_pLinkProc 要对事件进行处理的接口类
- bIsInsert 添加/删除定阅
- **【返回值】
- ****************************************************************/
- BOOL CPduEventHost::RegLinkProc(IPduLinkProc* a_pLinkProc, BOOL bIsInsert)
- {
- if(bIsInsert) // 添加定阅
- {
- m_listPduLinkProc.AddTail(a_pLinkProc);
- }
- else // 删除定阅
- {
- POSITION pos = m_listPduLinkProc.GetHeadPosition();
- while(pos != NULL)
- {
- POSITION posPrev = pos;
- IPduLinkProc* pNode = m_listPduLinkProc.GetNext(pos);
- if(pNode == a_pLinkProc)
- {
- m_listPduLinkProc.RemoveAt(posPrev);
- break;
- }
- } // end while
- } // end if
- return TRUE;
- }
- /*****************************************************************
- **【函数名称】 RegCommProc
- **【函数功能】 订阅消息通知事件
- **【参数】 a_pCommProc 要对事件进行处理的接口类
- bIsInsert 添加/删除定阅
- **【返回值】
- ****************************************************************/
- BOOL CPduEventHost::RegCommProc(IPduCommProc* a_pCommProc, BOOL bIsInsert)
- {
- if(bIsInsert) // 添加定阅
- {
- m_listPduCommProc.AddTail(a_pCommProc);
- }
- else // 删除定阅
- {
- POSITION pos = m_listPduCommProc.GetHeadPosition();
- while(pos != NULL)
- {
- POSITION posPrev = pos;
- IPduCommProc* pNode = m_listPduCommProc.GetNext(pos);
- if(pNode == a_pCommProc)
- {
- m_listPduCommProc.RemoveAt(posPrev);
- break;
- }
- } // end while
- } // end if
- return TRUE;
- }
- /*****************************************************************
- **【函数名称】 OnConnEstablisthed
- **【函数功能】 SOCKET连接建立事件处理
- **【参数】 linkContent 当前连接信息
- **【返回值】
- ****************************************************************/
- void CPduEventHost::OnLinkStateChanged(PduLinkContent& linkContent)
- {
- // 通知观查者
- POSITION pos = m_listPduLinkProc.GetHeadPosition();
- while(pos != NULL)
- {
- IPduLinkProc* pLinkProc = m_listPduLinkProc.GetNext(pos);
- pLinkProc->OnLinkStateChanged(linkContent);
- } // end while
- }
- /*****************************************************************
- **【函数名称】 OnRecvCommand
- **【函数功能】 PDU命令接收事件处理
- **【参数】 a_pCmd 命令实体
- **【返回值】
- ****************************************************************/
- void CPduEventHost::OnRecvCommand(CPduEntity* a_pCmd)
- {
- // 通知观查者
- POSITION pos = m_listPduCommProc.GetHeadPosition();
- while(pos != NULL)
- {
- IPduCommProc* pCommProc = m_listPduCommProc.GetNext(pos);
- pCommProc->OnRecvCommand(a_pCmd);
- } // end while
- }
|