|
-
June 8th, 2007, 04:43 AM
#1
Login problem of chatting program
I was programming a chatting software tools. But there is a problem on login. Client has a receiving threads to receive server`s message, When the client receives the message, A login sign will be marked (the sign is initializated '-1', if login failed it will be '0'. if login success it will be '1'). I want the client check this login sign from time to time . I would like to ask how to deal with this problem.
Code:
int g_iLoginACK = -1;
................................
extern int g_iLoginACK;
while( 1 != g_iLoginACK )
{
//Show LoginDialog
CLoginDlg *dlgLogin = new CLoginDlg();
int i = 2;
if( dlgLogin->DoModal() == IDOK )
{
// Get ID and Password
CString strID;
CString strPassword;
dlgLogin->GetIDAndPassword(strID, strPassword);
CString strSend;
strSend = "001"+strID+strPassword+"1";
m_sockP2P.SendTo(strSend, m_strServerIP, m_strServerPort);
DWORD dwStart = GetTickCount();
while( -1 == g_iLoginACK )
{
// Sleep(300);
}
// received login ACK
if( 1 == g_iLoginACK )
{
delete dlgLogin;
return true;
}
else
{
MessageBox("ID or Password Error", "Login Error!", MB_ICONERROR);
g_iLoginACK = -1;
continue;
delete dlgLogin;
}
}
else
{
delete dlgLogin;
return false;
}
}
return true;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|