Operator
C++ library for plugging into matrix.org
All Classes Namespaces Files Functions Typedefs Pages
Public Member Functions | Protected Attributes | List of all members
Operator::Client::HTTPClientAPI Class Reference

low-level Client-Server API over HTTP. More...

#include <http_client.hh>

Collaboration diagram for Operator::Client::HTTPClientAPI:
Collaboration graph
[legend]

Public Member Functions

 HTTPClientAPI (HTTP::Adapter &, const std::string &server)
 
void versions (const callback_t< const std::vector< std::string > &> &callback)
 get the versions of the specification supported by the server. More...
 
void login (const std::string &username, const std::string &password, const callback_t< const std::string &, const std::string &> &callback)
 log in using username and password More...
 
void loginWith3PID (const std::string &medium, const std::string &address, const std::string &password, const callback_t< const std::string &, const std::string &> &)
 log in using third party ID and pasword. More...
 
void loginWithToken (const std::string &token)
 log in with an access token that has previously been obtained.
 
void registerAccount (const std::string &username, const std::string &password, const callback_t< std::string, std::string > &)
 register a new account. More...
 
void logout (const callback_t<> &)
 log out. More...
 
bool isLoggedIn () const
 determine if the client is currently logged in.
 
const std::string & getToken () const
 return the access token for the client session.
 
void sync (const std::string &since, const std::string &filter, bool full_state, std::string set_presence, size_t timeout, const callback_t< const std::string &, nlohmann::json, nlohmann::json > &)
 get events from the server. More...
 
void roomMessages (const std::string &roomId, const std::string &from, const std::string &to, const std::string &dir, int limit, const callback_t< const std::string &, const std::string &, const std::vector< nlohmann::json > &> &)
 get messages/state events from a room. More...
 
void sendMessage (const std::string &roomId, const std::string &eventType, const std::string &txnId, const nlohmann::json &content, const callback_t< const std::string &> &)
 send a message event to a room. More...
 

Protected Attributes

HTTP::Adapteradapter
 
std::string baseurl
 

Detailed Description

low-level Client-Server API over HTTP.

See also
C-S r0.2.0
Examples:
liboperator-glib/examples/chathistory.cc, liboperator-glib/examples/send.cc, liboperator-glib/examples/sync.cc, liboperator-glib/examples/versions.cc, liboperator-qt/examples/chathistory.cc, liboperator-qt/examples/send.cc, liboperator-qt/examples/sync.cc, and liboperator-qt/examples/versions.cc.

Member Function Documentation

◆ login()

void HTTPClientAPI::login ( const std::string &  username,
const std::string &  password,
const callback_t< const std::string &, const std::string &> &  callback 
)

log in using username and password

Parameters
[in]usernameThe username to log in as
[in]passwordThe password to use
[out]callbackThe callback will receive the user's Matrix ID and the server name
See also
(C-S r0.2.0 section 3.2.1)
Examples:
liboperator-glib/examples/chathistory.cc, liboperator-glib/examples/send.cc, liboperator-glib/examples/sync.cc, liboperator-qt/examples/chathistory.cc, liboperator-qt/examples/send.cc, and liboperator-qt/examples/sync.cc.

◆ loginWith3PID()

void HTTPClientAPI::loginWith3PID ( const std::string &  medium,
const std::string &  address,
const std::string &  password,
const callback_t< const std::string &, const std::string &> &  callback 
)

log in using third party ID and pasword.

See also
(C-S r0.2.0 section 3.2.1)

◆ logout()

void HTTPClientAPI::logout ( const callback_t<> &  callback)

◆ registerAccount()

void Operator::Client::HTTPClientAPI::registerAccount ( const std::string &  username,
const std::string &  password,
const callback_t< std::string, std::string > &   
)

register a new account.

See also
(C-S r0.2.0 section 3.3.1)

◆ roomMessages()

void HTTPClientAPI::roomMessages ( const std::string &  roomId,
const std::string &  from,
const std::string &  to,
const std::string &  dir,
int  limit,
const callback_t< const std::string &, const std::string &, const std::vector< nlohmann::json > &> &  callback 
)

get messages/state events from a room.

See also
(C-S r0.2.0 section 6.3.5)
Examples:
liboperator-glib/examples/chathistory.cc, and liboperator-qt/examples/chathistory.cc.

◆ sendMessage()

void HTTPClientAPI::sendMessage ( const std::string &  roomId,
const std::string &  eventType,
const std::string &  txnId,
const nlohmann::json &  content,
const callback_t< const std::string &> &  callback 
)

send a message event to a room.

See also
(C-S r0.2.0 section 6.4.3)
Examples:
liboperator-glib/examples/send.cc, and liboperator-qt/examples/send.cc.

◆ sync()

void HTTPClientAPI::sync ( const std::string &  since,
const std::string &  filter,
bool  full_state,
std::string  set_presence,
size_t  timeout,
const callback_t< const std::string &, nlohmann::json, nlohmann::json > &   
)

◆ versions()

void HTTPClientAPI::versions ( const callback_t< const std::vector< std::string > &> &  callback)

get the versions of the specification supported by the server.

Parameters
[out]callbackThe callback will receive a vector of version strings.
See also
(C-S r0.2.0 section 2.1)
Examples:
liboperator-glib/examples/versions.cc, and liboperator-qt/examples/versions.cc.

The documentation for this class was generated from the following files: