thriftclient.cpp
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <account.h>
#include <connection.h>
#include <thrift/protocol/TCompactProtocol.h>
#include "constants.hpp"
#include "thriftclient.hpp"
ThriftClient::ThriftClient(PurpleAccount *acct, PurpleConnection *conn, std::string path)
: line::TalkServiceClient(
boost::make_shared<apache::thrift::protocol::TCompactProtocol>(
boost::make_shared<LineHttpTransport>(acct, conn, LINE_THRIFT_SERVER, 443, true))),
path(path)
{
http = boost::static_pointer_cast<LineHttpTransport>(getInputProtocol()->getTransport());
}
void ThriftClient::set_path(std::string path) {
this->path = path;
}
void ThriftClient::set_auto_reconnect(bool auto_reconnect) {
http->set_auto_reconnect(auto_reconnect);
}
void ThriftClient::send(std::function<void()> callback) {
http->request("POST", path, "application/x-thrift", callback);
}
int ThriftClient::status_code() {
return http->status_code();
}
void ThriftClient::close() {
http->close();
}
// Required for the single set<Contact> in the interface
bool line::Contact::operator<(const Contact &other) const {
return mid < other.mid;
}