12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- #include "StdAfx.h"
- #include "OnlineUser.h"
- COnlineUser::COnlineUser(void)
- {
- }
- COnlineUser::~COnlineUser(void)
- {
- }
- void COnlineUser::InsertOnlineUser(IN DWORD dwConnId, IN LPCTSTR lpAccount)
- {
- if ( IsAccountExist(lpAccount) != -1 )
- return;
- OnlineUser tagOnlineUser;
- tagOnlineUser.m_dwConnID = dwConnId;
- _stprintf_s(tagOnlineUser.m_szAccount, _T("%s"), lpAccount);
- m_OnlineUser.push_back(tagOnlineUser);
- }
- DWORD COnlineUser::IsAccountExist(IN LPCTSTR lpAccount )
- {
- BOOL bExist = FALSE;
- vector<OnlineUser>::iterator it = m_OnlineUser.begin();
- for ( ; it != m_OnlineUser.end(); it++ )
- {
- if ( _tcscmp(it->m_szAccount, lpAccount ) == 0 )
- {
- bExist = TRUE;
- break;
- }
- }
- return bExist ? it->m_dwConnID : -1;
- }
- BOOL COnlineUser::IsAccountExist(IN LPCTSTR lpAccount, OUT DWORD& dwConnId)
- {
- BOOL bExist = FALSE;
- vector<OnlineUser>::iterator it = m_OnlineUser.begin();
- for ( ; it != m_OnlineUser.end(); it++ )
- {
- if ( _tcscmp(it->m_szAccount, lpAccount ) == 0 )
- {
- dwConnId = it->m_dwConnID;
- bExist = TRUE;
- break;
- }
- }
- return bExist;
- }
- BOOL COnlineUser::IsConnIDExist(IN DWORD dwConnId)
- {
- BOOL bExist = FALSE;
- vector<OnlineUser>::iterator it = m_OnlineUser.begin();
- for ( ; it != m_OnlineUser.end(); it++ )
- {
- if ( dwConnId == it->m_dwConnID )
- {
- bExist = TRUE;
- break;
- }
- }
- return bExist;
- }
- void COnlineUser::EraseOnlineUser(IN DWORD dwConnId)
- {
- vector<OnlineUser>::iterator it = m_OnlineUser.begin();
- for ( ; it != m_OnlineUser.end(); )
- {
- if ( dwConnId == it->m_dwConnID )
- {
- it = m_OnlineUser.erase(it);
- break;
- }
- else
- {
- it++;
- }
- }
- }
|