Changeset af05fa1 in nscp for modules/NSCAClient/NSCAClient.cpp
- Timestamp:
- 05/13/12 22:08:01 (13 months ago)
- Branches:
- master, 0.4.1, 0.4.2
- Children:
- 695f240
- Parents:
- b5a03fe
- File:
-
- 1 edited
-
modules/NSCAClient/NSCAClient.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
modules/NSCAClient/NSCAClient.cpp
r308ae18 raf05fa1 29 29 #include <nsca/nsca_socket.hpp> 30 30 31 #include <nsca/client/nsca_client_protocol.hpp> 32 #include <socket/client.hpp> 33 31 34 #include <settings/client/settings_client.hpp> 32 35 #include <nscapi/nscapi_protobuf_functions.hpp> … … 378 381 // Protocol implementations 379 382 // 380 383 struct client_handler : public socket_helpers::client::client_handler { 384 unsigned int encryption_; 385 std::string password_; 386 client_handler(NSCAAgent::connection_data &con) 387 : socket_helpers::client::client_handler(con.host, con.port, con.timeout, false, "") 388 , encryption_(con.get_encryption()) 389 , password_(con.password) 390 { 391 392 } 393 void log_debug(std::string file, int line, std::string msg) const { 394 if (GET_CORE()->should_log(NSCAPI::log_level::debug)) { 395 GET_CORE()->log(NSCAPI::log_level::debug, file, line, utf8::to_unicode(msg)); 396 } 397 } 398 void log_error(std::string file, int line, std::string msg) const { 399 if (GET_CORE()->should_log(NSCAPI::log_level::error)) { 400 GET_CORE()->log(NSCAPI::log_level::error, file, line, utf8::to_unicode(msg)); 401 } 402 } 403 unsigned int get_encryption() { 404 return encryption_; 405 } 406 std::string get_password() { 407 return password_; 408 } 409 }; 381 410 boost::tuple<int,std::wstring> NSCAAgent::send(connection_data data, const std::list<nsca::packet> packets) { 382 411 try { 383 412 NSC_DEBUG_MSG_STD(_T("Connection details: ") + data.to_wstring()); 413 414 socket_helpers::client::client<nsca::client::protocol<client_handler> > client(boost::shared_ptr<client_handler>(new client_handler(data))); 415 client.connect(); 416 417 BOOST_FOREACH(const nsca::packet &packet, packets) { 418 NSC_DEBUG_MSG_STD(_T("Sending (data): ") + utf8::cvt<std::wstring>(packet.to_string())); 419 bool ret = client.process_request(packet); 420 } 421 client.shutdown(); 422 /* 384 423 boost::asio::io_service io_service; 385 424 nsca::socket socket(io_service); … … 395 434 } 396 435 socket.shutdown(); 436 */ 397 437 return boost::make_tuple(NSCAPI::returnUNKNOWN, _T("")); 398 438 } catch (const nsca::nsca_encrypt::encryption_exception &e) {
Note: See TracChangeset
for help on using the changeset viewer.








