예제 #1
0
파일: SeD.cpp 프로젝트: SysFera/vishnu
  void
  operator()() {
    Socket socket(*ctx_, ZMQ_REP);
    socket.connect(queue_.c_str());
    std::string data;
    while (true) {
      data.clear();
      try {
        data = socket.get();
      } catch (zmq::error_t &error) {
        LOG(boost::str(boost::format("[ERROR] %1%\n")
                       % error.what()), LogErr);
        continue;
      }

      // Deserialize and call the target method
      if (!data.empty()) {
        try {
          boost::shared_ptr<diet_profile_t> profile(my_deserialize(data));
          server_->call(profile.get()); //FIXME: deal with possibly error
          socket.send(my_serialize(profile.get()));
        } catch (const VishnuException& ex) {
          socket.send(ex.what());
          LOG(boost::str(boost::format("[ERROR] %1%\n")
                         % ex.what()), LogErr);
        }
      }
    }
  }
BOOST_FIXTURE_TEST_CASE(test_serialisation1,Fixture) {

    string str = my_serialize(g,s);
    ser_parameters *ser_par = deserialize(str);

    BOOST_CHECK_EQUAL(ser_par->s,s);
}