Commit ddb46385 authored by jan.koester's avatar jan.koester
Browse files

addclient added to api

parent ad10178b
Loading
Loading
Loading
Loading
Loading
+23 −1
Changes for client/client.cpp: 23 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -451,7 +451,29 @@ void authdb::client::Client::addConnection(const std::string &clientname,const s
    json_object *jresponse = json_object_new_object();
    json_object *cmd=json_object_new_array();
    json_object *obj=json_object_new_object();
    json_object *addclt=json_object_new_object();

    json_object_object_add(obj,"clientsession", json_object_new_string(_Con.getClientId().c_str()));
    json_object_object_add(obj,"usersession", json_object_new_string(_Con.getSessionID().c_str()));
    json_object_object_add(obj,"addclient", addclt);

    json_object_object_add(addclt,"name",json_object_new_string(clientname.c_str()));
    json_object_object_add(addclt,"secret",json_object_new_string(cltsecret.c_str()));

    json_object_array_add(cmd,obj);
    json_object_object_add(jresponse,"commands",cmd);

    size_t outsize=0;
    std::vector<char> out;

    const char *tmp=json_object_to_json_string_length(jresponse,0,&outsize);

    std::copy(tmp,tmp+outsize,std::back_inserter(out));

    libhttppp::HttpRequest nreq;
    nreq.setHeaderData("accept")->push_back("text/json");
    nreq.setRequestURL(_Con._Url.getPath().c_str());
    std::vector<char> resp(_Con._Client->Post(nreq,out));

    resp.push_back('\0');

}