/** * 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; }
/** * 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; }
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; }