本文整理汇总了C++中Store::JsonPaser方法的典型用法代码示例。如果您正苦于以下问题:C++ Store::JsonPaser方法的具体用法?C++ Store::JsonPaser怎么用?C++ Store::JsonPaser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Store
的用法示例。
在下文中一共展示了Store::JsonPaser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (){
boost::uuids::uuid m_UUID=boost::uuids::random_generator()();
long msg_id=0;
zmq::context_t *context=new zmq::context_t(3);
std::vector<Store*> RemoteServices;
std::string address("239.192.1.1");
//std::stringstream tmp ("5000");
int port=5000;
// tmp>>port;
ServiceDiscovery *SD=new ServiceDiscovery(address,port,context,320);
bool running=true;
zmq::socket_t Ireceive (*context, ZMQ_DEALER);
Ireceive.connect("inproc://ServiceDiscovery");
sleep(5);
zmq::message_t send(256);
snprintf ((char *) send.data(), 256 , "%s" ,"All NULL") ;
Ireceive.send(send);
zmq::message_t receive;
Ireceive.recv(&receive);
std::istringstream iss(static_cast<char*>(receive.data()));
int size;
iss>>size;
RemoteServices.clear();
for(int i=0;i<size;i++){
Store *service = new Store;
zmq::message_t servicem;
Ireceive.recv(&servicem);
std::istringstream ss(static_cast<char*>(servicem.data()));
service->JsonPaser(ss.str());
RemoteServices.push_back(service);
}
zmq::message_t tmp;
Ireceive.recv(&tmp);
/*
for(int i=0;i<RemoteServices.size();i++){
std::string ip;
std::string service;
std::string status;
//*(it->second)>> output;
ip=*((*(RemoteServices.at(i)))["ip"]);
service=*((*(RemoteServices.at(i)))["msg_value"]);
status=*((*(RemoteServices.at(i)))["status"]);
std::cout<<"["<<i<<"] "<<ip<<" , "<<service<<" , "<<status<<std::endl;
}
*/
/// webform
Cgicc formData;
cout << "Content-type:text/html\r\n\r\n";
cout<<"<html>";
cout<<" <head> <meta http-equiv=\"refresh\" content=\"60; url=./control.cgi\"> <meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\" /> <title>Remote ToolChain Control</title></head>";
cout<<" <link rel=\"stylesheet\" href=\"https://fonts.googleapis.com/icon?family=Material+Icons\">"; \
cout<<" <script defer src=\"https://code.getmdl.io/1.1.2/material.min.js\"></script>"; \
cout<<"<link rel=\"stylesheet\" href=\"https://code.getmdl.io/1.1.2/material.indigo-deep_purple.min.css\" />"; \
//.........这里部分代码省略.........
示例2: Initialise
bool Trigger::Initialise(std::string configfile, DataModel &data){
if(configfile!="") m_variables.Initialise(configfile);
//m_variables.Print();
m_data= &data;
m_variables.Get("verbose",m_verbose);
m_variables.Get("VME_service_name",VME_service_name);
m_variables.Get("numVME",numVME);
m_variables.Get("VME_port",VME_port);
m_data->triggered=false;
std::vector<Store*> RemoteServices;
zmq::socket_t Ireceive (*(m_data->context), ZMQ_DEALER);
Ireceive.connect("inproc://ServiceDiscovery");
for(int i=0;i<11;i++){
zmq::message_t send(256);
snprintf ((char *) send.data(), 256 , "%s" ,"All NULL") ;
Ireceive.send(send);
zmq::message_t receive;
Ireceive.recv(&receive);
std::istringstream iss(static_cast<char*>(receive.data()));
int size;
iss>>size;
for(int i=0;i<RemoteServices.size();i++){
delete RemoteServices.at(i);
RemoteServices.at(i)=0;
}
RemoteServices.clear();
for(int i=0;i<size;i++){
Store *service = new Store;
zmq::message_t servicem;
Ireceive.recv(&servicem);
std::istringstream ss(static_cast<char*>(servicem.data()));
service->JsonPaser(ss.str());
std::string servicetype;
service->Get("msg_value",servicetype);
//printf("%s \n",servicetype.c_str());
if(servicetype==VME_service_name) RemoteServices.push_back(service);
else delete service ;
}
if (RemoteServices.size()==numVME)break;
else usleep(1500000);
}
if (RemoteServices.size()!=numVME){
Log("ERROR!! Cant find all of the VME boards",0,m_verbose);
return false;
}
for(int i=0;i<RemoteServices.size();i++){
std::string ip;
//int logport=24010;
//*(it->second)>> output;
ip=*((*(RemoteServices.at(i)))["ip"]);
zmq::socket_t *RemoteSend = new zmq::socket_t(*(m_data->context), ZMQ_DEALER);
int a=12000;
RemoteSend->setsockopt(ZMQ_SNDTIMEO, a);
RemoteSend->setsockopt(ZMQ_RCVTIMEO, a);
std::stringstream tmp;
tmp<<"tcp://"<<ip<<":"<<VME_port;
// printf("%s \n",tmp.str().c_str());
RemoteSend->connect(tmp.str().c_str());
VMESockets.push_back(RemoteSend);
}
for(int i=0;i<RemoteServices.size();i++){
delete RemoteServices.at(i);
//.........这里部分代码省略.........