ParseMessage.cpp
资源名称:QQ示例源码.rar [点击查看]
上传用户:power_led
上传日期:2013-04-11
资源大小:373k
文件大小:2k
源码类别:
ICQ/即时通讯
开发平台:
Visual C++
- #include "Stdafx.h"
- #include "ParseMessage.h"
- #include "ClientSocket.h"
- #include "CChatServer.h"
- extern CCChatServerApp theApp;
- CParseMessage::~CParseMessage()
- {
- }
- CParseMessage::CParseMessage(const CMyTreeView * pWnd,const Message & Value)
- {
- pView = const_cast < CMyTreeView *>(pWnd);
- Msg = Value;
- }
- BOOL CParseMessage::SWitchMessage()
- {
- ASSERT(pView != NULL);
- ASSERT_VALID(pView);
- switch(Msg.iType)
- {
- case USERLOG:
- switch(Msg.iSubType)
- {
- case USERLOGIN:
- pView ->OnNewClientIn(Msg,0);
- break;
- default:
- break;
- }
- break;
- case USERSESSION:
- switch(Msg.iSubType)
- {
- default:
- break;
- case CHANGEROOM:
- pView ->OnChangeRoom(Msg,0);
- break;
- case SAYINPRIVATE:
- pView ->OnSendInPrivate(Msg,0);
- break;
- case USERQUIT:
- {
- g_cs.Lock();
- CString strUserName = Msg.strName;
- CString strRoomName = Msg.strRoom;
- CPtrList * m_pClientList = theApp.m_pClientSocketList;
- int iCount = m_pClientList->GetCount();
- POSITION pos = m_pClientList ->GetHeadPosition();
- POSITION tempos = pos;
- if(pos)
- {
- for(int i = 0; i < m_pClientList ->GetCount(); i++)
- {
- tempos = pos;
- CClientSocket *m_pClientSocket = static_cast < CClientSocket *>(m_pClientList->GetNext(pos));
- if(m_pClientSocket ->GetRoomName() == strRoomName && m_pClientSocket ->GetUserName() == strUserName)
- {
- m_pClientSocket ->ShutDown();
- m_pClientSocket ->Close();
- delete m_pClientSocket;
- m_pClientList->RemoveAt(tempos);
- break;
- }
- }
- g_cs.Unlock();
- }
- pView ->OnClientOut(Msg,0);
- }
- break;
- }
- break;
- default:
- break;
- }
- return TRUE;
- }