本文整理汇总了C++中intrusive_ptr::send方法的典型用法代码示例。如果您正苦于以下问题:C++ intrusive_ptr::send方法的具体用法?C++ intrusive_ptr::send怎么用?C++ intrusive_ptr::send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类intrusive_ptr
的用法示例。
在下文中一共展示了intrusive_ptr::send方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SearchCommand
FReturnCode NativeCommand::SearchCommand(intrusive_ptr< ConnectionInstance >& con, string& payload) {
//DLOG(INFO) << "Starting search with payload " << payload;
static string FKSstring("FKS");
static double timeout = 5.0;
double time = Server::getEventTime();
if (con->timers[FKSstring] > (time - timeout))
return FERR_THROTTLE_SEARCH;
else
con->timers[FKSstring] = time;
typedef list<ConnectionPtr> clst_t;
clst_t tosearch;
const conptrmap_t cons = ServerState::getConnections();
for (conptrmap_t::const_iterator i = cons.begin(); i != cons.end(); ++i) {
if ((i->second != con) && (i->second->kinkList.size() != 0) && (i->second->status == "online" || i->second->status == "looking"))
tosearch.push_back(i->second);
}
json_t* rootnode = json_loads(payload.c_str(), 0, 0);
if (!rootnode)
return FERR_BAD_SYNTAX;
json_t* kinksnode = json_object_get(rootnode, "kinks");
if (!json_is_array(kinksnode))
return FERR_BAD_SYNTAX;
if (json_array_size(kinksnode) > 5)
return FERR_TOO_MANY_SEARCH_TERMS;
json_t* gendersnode = json_object_get(rootnode, "genders");
if (json_is_array(gendersnode))
SearchFilterList(gendersnode, tosearch, "Gender");
json_t* orientationsnode = json_object_get(rootnode, "orientations");
if (json_is_array(orientationsnode))
SearchFilterList(orientationsnode, tosearch, "Orientation");
json_t* languagesnode = json_object_get(rootnode, "languages");
if (json_is_array(languagesnode))
SearchFilterList(languagesnode, tosearch, "Language preference");
json_t* furryprefsnode = json_object_get(rootnode, "furryprefs");
if (json_is_array(furryprefsnode))
SearchFilterList(furryprefsnode, tosearch, "Furry preference");
json_t* rolesnode = json_object_get(rootnode, "roles");
if (json_is_array(rolesnode))
SearchFilterList(rolesnode, tosearch, "Dom/Sub Role");
json_t* positionsnode = json_object_get(rootnode, "positions");
if (json_is_array(positionsnode))
SearchFilterList(positionsnode, tosearch, "Position");
if (json_array_size(kinksnode) > 0)
SearchFilterListF(kinksnode, tosearch);
int num_found = tosearch.size();
if (num_found == 0)
return FERR_NO_SEARCH_RESULTS;
else if (num_found > 350)
return FERR_TOO_MANY_SEARCH_RESULTS;
json_t* newroot = json_object();
json_t* chararray = json_array();
for (clst_t::const_iterator i = tosearch.begin(); i != tosearch.end(); ++i) {
json_array_append_new(chararray,
json_string_nocheck((*i)->characterName.c_str())
);
}
json_object_set_new_nocheck(newroot, "characters", chararray);
json_object_set_new_nocheck(newroot, "kinks", kinksnode);
string message("FKS ");
const char* fksstr = json_dumps(newroot, JSON_COMPACT);
message += fksstr;
free((void*) fksstr);
json_decref(newroot);
MessagePtr outMessage(MessageBuffer::FromString(message));
con->send(outMessage);
json_decref(rootnode);
//DLOG(INFO) << "Finished search.";
return FERR_OK;
}