void UploadMessage(int argc, char *argv[], BBWinNet & bbobj) { cout << "Uploading message ...\n"; try { string res; ostringstream tosend; string line; ifstream myfile ( argv[3] ); if (myfile.is_open()) { while (! myfile.eof() ) { getline (myfile,line); tosend << line << endl; } myfile.close(); } else cout << "Unable to open file"; bbobj.Message(tosend.str(), res); cout << "Uploading message done !" ; cout << "\n" << res << "\n\n"; } catch (BBWinNetException ex) { cout << "Error : " << ex.getMessage() << "\n"; } }
void Message(int argc, char *argv[], BBWinNet & bbobj) { cout << "Sending message ...\n"; try { string res; bbobj.Message(argv[3], res); cout << "\n" << res << "\n\n"; } catch (BBWinNetException ex) { cout << "Error : " << ex.getMessage() << "\n"; } }
void BBWinAgentManager::Message(LPCTSTR message, LPTSTR dest, DWORD size) { bbdisplay_t::iterator itr; BBWinNet hobNet; string result; assert(message != NULL); assert(dest != NULL); if (m_usepager == true && m_bbpager.size() > 0) { // extract the information needed to send pager notification string tmp, type, testName, color, text, lifeTime; size_t pos = 0; tmp = message; istringstream iss(tmp); std::getline( iss, tmp); size_t res = tmp.find_first_of(" "); if (res > 0 && res < tmp.length()) { type = tmp.substr(0, res); res = type.find_first_of("status"); if (res >= 0 && res < tmp.length()) { size_t end; tmp = tmp.substr(type.length() + 1); pos += type.length() + 1; res = type.find_first_of("+"); if (res > 0 && res < type.length()) { lifeTime = type.substr(res + 1); } res = tmp.find_first_of("."); end = tmp.find_first_of(" "); testName = tmp.substr(res + 1, end - (res + 1)); tmp = tmp.substr(end + 1); pos += end + 1; end = tmp.find_first_of(" "); color = tmp.substr(0, end); if (tmp.length() > (end + 2)) { pos += end + 2; text = message; text = text.substr(pos); Pager(testName.c_str(), color.c_str(), text.c_str(), lifeTime.c_str()); } } } } for ( itr = m_bbdisplay.begin(); itr != m_bbdisplay.end(); ++itr) { hobNet.SetBBDisplay((*itr)); PrepareBBWinNetObj(hobNet); try { hobNet.Message(message, result); } catch (BBWinNetException ex) { if (m_logReportFailure) { string mes; mes = "Sending report to " + (*itr) + " failed."; LPCTSTR arg[] = {m_agentName.c_str(), mes.c_str(), NULL}; m_log->reportWarnEvent(BBWIN_AGENT, EVENT_MESSAGE_AGENT, 2, arg); } continue ; } } try { if (dest != NULL && size != 0) strncpy(dest, result.c_str(), size); } catch (...) { // Failed to write } }