ServerService.h
上传用户:hysujiao87
上传日期:2007-12-02
资源大小:156k
文件大小:2k
- #pragma once
- #include "UserList.h" // Added by ClassView
- #define WM_SERVICE_NOTIFY WM_USER + 101
- typedef struct tagListenParam
- {
- CUserList *list;
- CEvent *finishEvent;
- }LISTEN_PARAM;
- #define DEAL_REQUEST_BEGIN()
- _ASSERTE(request != NULL && responseRoot != NULL);
- if (request == NULL || responseRoot == NULL)
- return E_INVALIDARG;
- CElement *requestRoot = request->get_root();
- _ASSERTE(requestRoot != NULL);
- if (requestRoot == NULL)
- return E_POINTER;
- class CXMLParser;
- class CElement;
- class CServerService
- {
- public:
- CServerService(void);
- ~CServerService(void);
- static HRESULT dealRequest(BYTE *data,
- int dataLen,
- const SOCKET &sock,
- const sockaddr_in &addrFrom,
- CUserList *list);
- HRESULT startListen(CUserList *list);
- HRESULT stopListen();
- BOOL isListening(){
- return _listenThread != NULL;
- }
- protected:
- HANDLE _listenThread;
- CEvent _finishEvent;
- CUserList *_list;
- static UINT serviceProc(LPVOID wParam);
- static CString logMessage(CXMLParser *msg, const sockaddr_in &addrFrom);
- static HRESULT dealLogOnRequest(CXMLParser *request, CElement *responseRoot, CUserList &list);
- static HRESULT dealLogOffRequest(CXMLParser *request, CElement *responseRoot, CUserList &list);
- static HRESULT dealRegisterRequest(CXMLParser *request, CElement *responseRoot, CUserList &list);
- static HRESULT dealAddFriendRequest(CXMLParser *request, CElement *responseRoot, CUserList &list);
- static HRESULT dealDownloadFriendsRequest(CXMLParser *request, CElement *responseRoot, CUserList &list);
- static HRESULT dealQueryUserRequest(CXMLParser *request, CElement *responseRoot, CUserList &list);
- static HRESULT dealOnlineRequest(CXMLParser *request, CElement *responseRoot, const sockaddr_in &addrFrom, CUserList &list);
- };