Ignore:
Timestamp:
09/02/11 07:38:44 (21 months ago)
Author:
Michael Medin <michael@…>
Branches:
master, 0.4.0, 0.4.1, 0.4.2
Children:
a14aa07
Parents:
3b11e65
Message:
  • Implemented registration of channels (so no longer faked)
  • Added settings key to change the NSCAAgent channel name
  • Addded proper channel handling to PythonScript module
  • Improved error handling in channels API
  • Rewrote wrapper API to use templates and classes instead of macros (ish)
  • Improved the internal plugin wrapping API to support multiple plugin load
  • Fixed so PythonScript module supports multiple plugin load (with new argument for plugin_id)
  • Added API for registrying routers and handling routing (almost there now)
  • Fixed issue with messages due to new API
File:
1 edited

Legend:

Unmodified
Added
Removed
  • include/nscapi/nscapi_core_wrapper.cpp

    rd7e265d ra44cb15  
    129129  std::string request; 
    130130  nscapi::functions::create_simple_query_response(command, code, message, perf, request); 
    131   NSCAPI::nagiosReturn ret = NotifyChannel(channel, command, code, request); 
    132 } 
    133  
    134  
    135 NSCAPI::errorReturn nscapi::core_wrapper::NotifyChannel(std::wstring channel, std::wstring command, NSCAPI::nagiosReturn code, std::string result) { 
     131  NSCAPI::nagiosReturn ret = submit_message(channel, command, request); 
     132} 
     133 
     134NSCAPI::errorReturn nscapi::core_wrapper::submit_message(std::wstring channel, std::wstring command, std::string buffer) { 
    136135  if (!fNSAPINotify) 
    137136    throw nscapi::nscapi_exception(_T("NSCore has not been initiated...")); 
    138   return fNSAPINotify(channel.c_str(), command.c_str(), code, result.c_str(), result.size()); 
     137  return fNSAPINotify(channel.c_str(), command.c_str(), buffer.c_str(), buffer.size()); 
    139138} 
    140139 
     
    544543  return ret; 
    545544} 
    546 void nscapi::core_wrapper::registerCommand(std::wstring command, std::wstring description) { 
     545void nscapi::core_wrapper::registerCommand(unsigned int id, std::wstring command, std::wstring description) { 
    547546  if (!fNSAPIRegisterCommand) 
    548547    throw nscapi::nscapi_exception(_T("NSCore has not been initiated...")); 
    549   if (fNSAPIRegisterCommand(id_, command.c_str(), description.c_str()) != NSCAPI::isSuccess) { 
    550     CORE_LOG_ERROR_STD(_T("Failed to register command: ") + command + _T(" in plugin: ") + to_wstring(id_)); 
     548  if (fNSAPIRegisterCommand(id, command.c_str(), description.c_str()) != NSCAPI::isSuccess) { 
     549    CORE_LOG_ERROR_STD(_T("Failed to register command: ") + command + _T(" in plugin: ") + to_wstring(id)); 
     550  } 
     551} 
     552 
     553void nscapi::core_wrapper::registerSubmissionListener(unsigned int id, std::wstring channel) { 
     554  if (!fNSAPIRegisterSubmissionListener) 
     555    throw nscapi::nscapi_exception(_T("NSCore has not been initiated...")); 
     556  if (fNSAPIRegisterSubmissionListener(id, channel.c_str()) != NSCAPI::isSuccess) { 
     557    CORE_LOG_ERROR_STD(_T("Failed to register channel: ") + channel + _T(" in plugin: ") + to_wstring(id)); 
     558  } 
     559} 
     560void nscapi::core_wrapper::registerRoutingListener(unsigned int id, std::wstring channel) { 
     561  if (!fNSAPIRegisterRoutingListener) 
     562    throw nscapi::nscapi_exception(_T("NSCore has not been initiated...")); 
     563  if (fNSAPIRegisterRoutingListener(id, channel.c_str()) != NSCAPI::isSuccess) { 
     564    CORE_LOG_ERROR_STD(_T("Failed to register channel: ") + channel + _T(" in plugin: ") + to_wstring(id)); 
    551565  } 
    552566} 
     
    583597 * @return NSCAPI::success or NSCAPI::failure 
    584598 */ 
    585 bool nscapi::core_wrapper::load_endpoints(unsigned int id, nscapi::core_api::lpNSAPILoader f) { 
    586   id_ = id; 
     599bool nscapi::core_wrapper::load_endpoints(nscapi::core_api::lpNSAPILoader f) { 
    587600  fNSAPIGetApplicationName = (nscapi::core_api::lpNSAPIGetApplicationName)f(_T("NSAPIGetApplicationName")); 
    588601  fNSAPIGetApplicationVersionStr = (nscapi::core_api::lpNSAPIGetApplicationVersionStr)f(_T("NSAPIGetApplicationVersionStr")); 
     
    624637  fNSAPIExpandPath = (nscapi::core_api::lpNSAPIExpandPath)f(_T("NSAPIExpandPath")); 
    625638   
     639  fNSAPIRegisterSubmissionListener = (nscapi::core_api::lpNSAPIRegisterSubmissionListener)f(_T("NSAPIRegisterSubmissionListener")); 
     640  fNSAPIRegisterRoutingListener = (nscapi::core_api::lpNSAPIRegisterRoutingListener)f(_T("NSAPIRegisterRoutingListener")); 
     641 
    626642  return true; 
    627643} 
Note: See TracChangeset for help on using the changeset viewer.