DWORD CLoginDlg::userProfile(LPCTSTR serverURL, LPCTSTR requestPage) { #ifdef _HTTPS CInternetSession session(_T("HelloChat"), INTERNET_FLAG_SECURE); CHttpConnection* pConnection = session.GetHttpConnection(serverURL, INTERNET_SERVICE_HTTP, INTERNET_DEFAULT_HTTPS_PORT); CString strToken = L"token:"; strToken = strToken + m_strMyToken + L"\r\n"; CHttpFile* pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_GET, requestPage, NULL, 1, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_NO_COOKIES); #else CInternetSession session(_T("HelloChat"), PRE_CONFIG_INTERNET_ACCESS); CHttpConnection* pConnection = session.GetHttpConnection(serverURL); CString strToken = L"token:"; //strToken = strToken + m_strToken + L"\r\n"; strToken = strToken + m_strMyToken + L"\r\n"; CHttpFile* pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_GET, requestPage, NULL, 1, NULL, NULL, INTERNET_FLAG_RELOAD | INTERNET_FLAG_DONT_CACHE | INTERNET_FLAG_NO_COOKIES); #endif VERIFY(pFile->AddRequestHeaders(HEADER)); VERIFY(pFile->AddRequestHeaders(strToken)); VERIFY(pFile->SendRequest()); // GET POST STATUS DWORD dwPostStatus = 0; VERIFY(pFile->QueryInfoStatusCode(dwPostStatus)); CString strBuffer = L""; BOOL brtn = pFile->ReadString(strBuffer); char* rtnBuffer = LPSTR(LPCTSTR(strBuffer)); if (dwPostStatus == HTTP_STATUS_OK) { BOOL bRtn = dataParser(rtnBuffer); if (!bRtn){ AfxMessageBox(L"User Info Paser Error"); } } else{ CComm func; func.WriteErrorLog(rtnBuffer); } pFile->Close(); return dwPostStatus; }
void connectionManager::run(){ char *lpBuffer = new char[30]; while(true){ if(serial.ReadDataWaiting()){ try{ int bytesRead = serial.ReadData(lpBuffer,30); dataParser(lpBuffer,bytesRead); } catch(exception ex){ cout<<ex.what()<<endl; } } else{ Sleep(1); } } delete []lpBuffer; if(serial.IsOpened()) serial.Close(); }