Urgent please, Iterators and Sockets
Posted on 2003-11-11
I have a server app that listens for clients to connect, when they do so they are entered into a CTypedPtrList with their socket and username.
When this is done during the login, i want to be able to send all the clients a list of who is online which i have tried to do here but it only sends one username to each client which is their own name.
if you need more info or more code just ask.
void CSockServerDlg::doLogin(CConnUser* theUser, CString dataRcvd)
char *pBuf = new char;
char seps = " ";
pBuf = dataRcvd.GetBuffer(1025);
token = strtok(pBuf, seps );
CString UserName = token;
token = strtok(NULL,seps);
CString password = token;
if (true)//test for something
CConnUser *iterator = NULL; //added
POSITION pos = m_ConnUserList.GetHeadPosition();
if ( pos == NULL )
; // do something
iterator = m_ConnUserList.GetAt(pos); //added
CString m_pViewFind = (iterator->Username()); //added
//m_pViewFind added inplace of UserName
CString buddyList = " BUDDYLIST " + m_pViewFind ;
//send one message to everyone