本文整理汇总了C++中rho::apigenerator::CMethodResult::setRubyCallback方法的典型用法代码示例。如果您正苦于以下问题:C++ CMethodResult::setRubyCallback方法的具体用法?C++ CMethodResult::setRubyCallback怎么用?C++ CMethodResult::setRubyCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rho::apigenerator::CMethodResult
的用法示例。
在下文中一共展示了CMethodResult::setRubyCallback方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: search
void RhoConnectClientImpl::search( const rho::Hashtable<rho::String, rho::String>& args, rho::apiGenerator::CMethodResult& oResult) {
getSyncThread()->stopAll();
bool syncChanges = false;
int progressStep = -1;
rho::Vector<rho::String> sources;
rho::String searchParams;
rho::String from = "search";
/* handle old-style callback setting */
if (args.containsKey("callback")) {
oResult.setRubyCallback(args.get("callback"));
if (args.containsKey("callback_param")) {
oResult.setCallbackParam(args.get("callback_param"));
}
}
if (args.containsKey("from") ) {
from = args.get("from");
}
/*this will return new arg value, overriding deprecated one, if it is present*/
struct DeprecatedArgsHandler {
static bool getArgValue( const rho::Hashtable<rho::String, rho::String>& args, const rho::String& newArgName, const rho::String& deprecatedArgName, rho::String& realArgValue ) {
bool found = false;
if ( args.containsKey(deprecatedArgName) ) {
RAWLOG_WARNING2("'%s' argument is deprecated for search. Use '%s' instead.",deprecatedArgName.c_str(),newArgName.c_str());
realArgValue = args.get(deprecatedArgName);
found = true;
}
if ( args.containsKey(newArgName) ) {
realArgValue = args.get(newArgName);
found = true;
}
return found;
}
};
String jsonSources;
if ( DeprecatedArgsHandler::getArgValue(args,"sourceNames","source_names",jsonSources) ) {
rho::json::CJSONEntry json(jsonSources.c_str());
if ( json.isArray() ) {
for( rho::json::CJSONArrayIterator array(json); !array.isEnd(); array.next()) {
sources.push_back( array.getCurItem().getString() );
}
}
}
if (args.containsKey("offset")) {
searchParams += "&offset=" + rho::net::URI::urlEncode(args.get("offset"));
}
rho::String maxResults;
if ( DeprecatedArgsHandler::getArgValue(args,"maxResults","max_results",maxResults) ) {
searchParams += "&max_results=" + rho::net::URI::urlEncode(maxResults);
}
rho::String jsonSearchParams;
if ( DeprecatedArgsHandler::getArgValue(args,"searchParams","search_params",jsonSearchParams) ) {
rho::json::CJSONEntry json(jsonSearchParams.c_str());
if ( json.isObject() ) {
for ( rho::json::CJSONStructIterator obj(json); !obj.isEnd(); obj.next() ) {
rho::String key = rho::net::URI::urlEncode(obj.getCurKey());
rho::String value = rho::net::URI::urlEncode(obj.getCurValue().getString());
searchParams += "&search[" + key + "]=" + value;
}
}
}
rho::String strSyncChanges;
if ( DeprecatedArgsHandler::getArgValue(args,"syncChanges","sync_changes",strSyncChanges) ) {
syncChanges = (strSyncChanges=="true") || (strSyncChanges=="1");
}
rho::String strProgressStep;
if ( DeprecatedArgsHandler::getArgValue(args,"progressStep","progress_step",strProgressStep) ) {
progressStep = atoi(strProgressStep.c_str());
}
getSyncEngine().getNotify().setSearchNotification( new sync::CSyncNotification(oResult, true) );
getSyncThread()->addQueueCommand(new sync::CSyncThread::CSyncSearchCommand(from,searchParams,sources,syncChanges,progressStep) );
handleSyncResult(oResult);
}
示例2: setNetworkStatusNotify
void CSystemImplBase::setNetworkStatusNotify( const rho::String& url, int poll_interval, rho::apiGenerator::CMethodResult& oResult)
{
oResult.setRubyCallback(url);
RHODESAPP().setNetworkStatusNotify( oResult, (int)poll_interval );
}