UserList.h
上传用户:hysujiao87
上传日期:2007-12-02
资源大小:156k
文件大小:2k
- // UserList.h: interface for the CUserRecord class.
- //
- //////////////////////////////////////////////////////////////////////
- #if !defined(AFX_USERRECORD_H__5D62B780_8E65_11D6_9C0E_0080C8F72DA3__INCLUDED_)
- #define AFX_USERRECORD_H__5D62B780_8E65_11D6_9C0E_0080C8F72DA3__INCLUDED_
- #if _MSC_VER > 1000
- #pragma once
- #endif // _MSC_VER > 1000
- #include "friendDef.h"
- class CUserData : public CObject
- {
- public:
- CString _clientID;
- CString _password;
- CString _nickname;
- BOOL _online;
- sockaddr_in _sockAddr;
- DWORD _lastReport;
- CUserData();
- ~CUserData();
- void Serialize(CArchive &ar);
- void operator = (CUserData& data);
- HRESULT addFriend(LPCTSTR friendID);
- void clear();
- int getFriendCount(){
- return _friendList.size();
- }
- CString getFriendID(int index){
- if (index >= (int)_friendList.size())
- return CString(_T(""));
- return _friendList[index]->userID;
- }
- protected:
- FriendVector _friendList;
- DECLARE_DYNCREATE(CUserData)
- };
- class CUserList : public CObject
- {
- public:
- CUserList();
- ~CUserList();
- void addUser(CUserData* userData);
- void removeAll();
- CUserData* getUserByID(LPCTSTR userID);
- CUserData* getUserByIndex(INT_PTR index);
-
- INT_PTR getCount(){
- CSingleLock lock(&_mutex, TRUE);
- _ASSERTE(lock.IsLocked() == TRUE);
- if (lock.IsLocked() != TRUE)
- return 0;
- return _userList.GetCount();
- }
- HRESULT authenticate(LPCTSTR userID, LPCTSTR password);
- void Serialize(CArchive &ar);
- protected:
- CMutex _mutex;
- CTypedPtrList <CPtrList, CUserData*> _userList;
- DECLARE_DYNCREATE(CUserList)
- };
- #endif // !defined(AFX_USERRECORD_H__5D62B780_8E65_11D6_9C0E_0080C8F72DA3__INCLUDED_)