Exemple #1
0
/**
 * Build a response text based on result from server method
 */
std::string Proto::build_response(Response& resp) {
  JObject* obj = new JObject();
  obj->put(Result, resp.get_serializer().getContent());

  std::string jsonText = dumps(obj);
  delete obj;
  return jsonText; 
}
Exemple #2
0
/**
 * Build an error message given error code
 */
std::string Proto::build_error(int code) {
  JObject* obj = new JObject();
  obj->put(Error, code);

  std::string jsonText = dumps(obj);
  delete obj;
  return jsonText;
}
Exemple #3
0
std::string Proto::build_request(
                     int clientno, int serverno,
                     int messageid, long timestamp,
                     size_t method_hash, OutSerializer& sout) {
  JObject* obj = new JObject();
  obj->put(ClientNo, clientno);
  obj->put(ServerNo, serverno);
  obj->put(Version, 1);
  obj->put(Timestamp, timestamp);
  obj->put(MessageId, messageid);
  obj->put(Method, method_hash);
  obj->put(Param, sout.getContent());

  std::string msg = dumps(obj);
  delete obj;
  return msg;
}