1. server信息如何传递到client应用层?
void CConference::OnReceiveData(CRtMessageBlock& data)
{
CRtAutoPtr<CInfoSvrPduBase> decPdu;
RtResult ret = CInfoSvrPduBase::DecodePdu(data, decPdu.ParaOut());
....
CInfoSvrPduBase* pdu = decPdu.Get();
....
switch(pdu->GetType())
{
......
//Conference message
case INFO_SVR_PDU_TYPE_CONF_JOIN_RSPN: // 所以,要到CConference才会对Data的业务含义进行解析
HandleJoinConfRspn((CInfoSvrJoinConfRspnPdu*) pdu);
break;
...
}
STACK TRACE:
CConference::OnReceiveData(CRtMessageBlock & {...}) line 1365
CConfConnection::OnReceiveData(CRtMessageBlock & {...}, IConnection * 0x0205de84) line 170
CRtIMConnection::OnReceive(CRtMessageBlock & {...}, IRtTransport * 0x0205b590, CRtTransportParameter * 0x00000000) line 890 + 50 bytes
CRtEventOnReceive::OnEventFire() line 375 + 50 bytes
CRtEventQueueBase::ProcessOneEvent(IRtEvent * 0x0205b278) line 229 + 12 bytes
CRtEventQueueBase::ProcessEvents(const std::list<IRtEvent *,std::allocator<IRtEvent *> > & {...}) line 217
CRtReactorBase::ProcessHandleEvent(void * 0xffffffff, long 256, int 0, int 1, int 0) line 324 + 18 bytes
CRtReactorWin32Message::Win32SocketWndProc(HWND__ * 0x00130946, unsigned int 1058, unsigned int 4294967295, long 256) line 115
USER32! 77d18734()
USER32! 77d18816()
USER32! 77d189cd()
USER32! 77d196c7()
WTL::CMessageLoop::Run() line 468 + 15 bytes
Run(char * 0x00151f28, int 1) line 207 + 11 bytes
LaunchConf(HINSTANCE__ * 0x00400000, char * 0x00151f28, int 1) line 318 + 13 bytes
WinMain(HINSTANCE__ * 0x00400000, HINSTANCE__ * 0x00000000, char * 0x00151f28, int 1) line 85 + 20 bytes
WinMainCRTStartup() line 330 + 54 bytes
KERNEL32! 7c817077()
Q:Win32SockWndProc也是一种消息处理?由消息映射来映射的?
A:exactly!
class CRtReactorWin32Message : public CRtReactorBase
{
public:
CRtReactorWin32Message();
virtual ~CRtReactorWin32Message();
......
protected:
virtual RtResult OnHandleRegister(RT_HANDLE aFd,
IRtEventHandler::MASK aMask, IRtEventHandler *aEh);
virtual void OnHandleRemoved(RT_HANDLE aFd);
static LRESULT CALLBACK Win32SocketWndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
Q: when to be called by whom ???
A:当任何程序通过PostMessage()发送几个消息(比如与socket有关的)的时候,此函数被调用。如,在Reactor::NotifyHandler()中。2011/12/04
HWND m_hwndNotify;
UINT m_dwTimerId;
};
总结一下:
* 发送:消息->消息处理函数->通过Session代码发送出去
* 接收:特殊消息->消息处理函数->通过Session代码接收进来