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

Matrix client interface for high-level API.This interface is implemented by the high-level API classes. All high-level API classes implement this, no matter which low-level API is used (e.g. HTTP) More...

#include <client.hh>

Inheritance diagram for Operator::Client::Client:
Inheritance graph
[legend]

Classes

class  Room
 

Public Member Functions

virtual void login (const std::string &username, const std::string &password, const callback_t< const std::string &, const std::string &> &=noop_callback< const std::string &, const std::string &>)=0
 log in using username and password More...
 
virtual void loginWith3PID (const std::string &medium, const std::string &address, const std::string &password, const callback_t< const std::string &, const std::string &> &=noop_callback< const std::string &, const std::string &>)=0
 log in using third party ID and pasword. More...
 
virtual void logout (const callback_t<> &=noop_callback<>)=0
 log out. More...
 
virtual bool isLoggedIn () const =0
 determine if the client is currently logged in.
 
virtual void startClient ()=0
 start listening for new events.
 
virtual void stopClient ()=0
 stop listening for new events.
 
virtual void sendMessage (const Event::MessageEvent &message, const callback_t< const std::string &> &callback=noop_callback< const std::string &>)=0
 send a message event. More...
 
RoomgetRoom (const std::string &room_id)
 return the room with the given ID. More...
 
const RoomgetRoom (const std::string &room_id) const throw (std::out_of_range)
 
Roomoperator[] (const std::string &room_id)
 
const Roomoperator[] (const std::string &room_id) const throw (std::out_of_range)
 
void on (const std::string &type, const callback_t< Room &, const Event::Event &> &callback)
 register an event handler. More...
 
template<class T >
void on (const callback_t< Room &, const Event::Event &> &callback)
 register an event handler. More...
 

Protected Member Functions

void trigger (const Event::Event &event)
 call event handlers for the given event.
 
void triggerError (const std::string &event_type, std::shared_ptr< Error::Error > error, const std::string &room_id="")
 
void _setRoomMembership (Room &room, Event::RoomMembership::membership_t membership)
 

Protected Attributes

std::map< std::string, Roomrooms
 

Detailed Description

Matrix client interface for high-level API.

This interface is implemented by the high-level API classes. All high-level API classes implement this, no matter which low-level API is used (e.g. HTTP)

Examples:
liboperator-glib/examples/echo.cc, and liboperator-qt/examples/echo.cc.

Member Function Documentation

◆ getRoom()

Room& Operator::Client::Client::getRoom ( const std::string &  room_id)
inline

return the room with the given ID.

Parameters
[in]room_idThe room ID.

◆ login()

virtual void Operator::Client::Client::login ( const std::string &  username,
const std::string &  password,
const callback_t< const std::string &, const std::string &> &  = noop_callback< const std::string &, const std::string &> 
)
pure virtual

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)

Implemented in Operator::Client::HTTPClient.

◆ loginWith3PID()

virtual void Operator::Client::Client::loginWith3PID ( const std::string &  medium,
const std::string &  address,
const std::string &  password,
const callback_t< const std::string &, const std::string &> &  = noop_callback< const std::string &, const std::string &> 
)
pure virtual

log in using third party ID and pasword.

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

Implemented in Operator::Client::HTTPClient.

◆ logout()

virtual void Operator::Client::Client::logout ( const callback_t<> &  = noop_callback<>)
pure virtual

log out.

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

Implemented in Operator::Client::HTTPClient.

Examples:
liboperator-glib/examples/echo.cc, and liboperator-qt/examples/echo.cc.

◆ on() [1/2]

void Operator::Client::Client::on ( const std::string &  type,
const callback_t< Room &, const Event::Event &> &  callback 
)

register an event handler.

Register an event handler to be called when an event of the given type is received.

Parameters
[in]typeThe event type, or "*" for all events.
[out]callbackThe callback will receive the room that the event belongs to and the event.
Examples:
liboperator-glib/examples/echo.cc, and liboperator-qt/examples/echo.cc.

◆ on() [2/2]

template<class T >
void Operator::Client::Client::on ( const callback_t< Room &, const Event::Event &> &  callback)
inline

register an event handler.

Register an event handler to be called when an event of the given type is received.

Note
This is just syntactic sugar for on(T::TYPE, callback). That is, when determining which callbacks to call, it only compares the event's type field with T::TYPE, and does not check the actual class of the event generated. One consequence of this is that event passed to the callback may not necessarily be an object of class T.
Template Parameters
Tthe event class (use Operator::Event::Event for all events)
Parameters
[out]callbackThe callback will receive the room that the event belongs to and the event.

◆ sendMessage()

virtual void Operator::Client::Client::sendMessage ( const Event::MessageEvent message,
const callback_t< const std::string &> &  callback = noop_callback< const std::string &> 
)
pure virtual

send a message event.

Parameters
[in]messageThe message event to send.
[out]callbackThe callback will receive the resulting event ID.

Implemented in Operator::Client::HTTPClient.

Examples:
liboperator-glib/examples/echo.cc, and liboperator-qt/examples/echo.cc.

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