libkazv
Kazv::Room Class Reference

Represent a Matrix room. More...

#include <room.hpp>

Classes

struct  InEventLoopTag
 

Public Types

using PromiseT = SingleTypePromise< DefaultRetType >
 
using DepsT = lager::deps< SdkModelCursorKey, RandomInterface & >
 
using ContextT = Context< ClientAction >
 

Public Member Functions

 Room (lager::reader< SdkModel > sdk, lager::reader< std::string > roomId, ContextT ctx)
 Constructor. More...
 
 Room (lager::reader< SdkModel > sdk, lager::reader< std::string > roomId, ContextT ctx, DepsT deps)
 Constructor. More...
 
 Room (InEventLoopTag, std::string roomId, ContextT ctx, DepsT deps)
 Construct a Room in the same thread as the event loop. More...
 
Room toEventLoop () const
 Return a Room that represents the room currently represented by this, but suitable for use in the event loop of the context. More...
 
auto stateEvents () const
 
auto inviteState () const -> lager::reader< immer::map< KeyOfState, Event >>
 Get the invite_state of this room. More...
 
auto stateOpt (KeyOfState k) const
 
auto state (KeyOfState k) const
 
auto timelineEventIds () const -> lager::reader< immer::flex_vector< std::string >>
 Get the timeline event ids of this room in ascending timestamp order. More...
 
auto messagesMap () const -> lager::reader< immer::map< std::string, Event >>
 Get a map from event ids to events. More...
 
auto timelineEvents () const -> lager::reader< immer::flex_vector< Event >>
 Get a list of timeline events in this room. More...
 
auto message (lager::reader< std::string > eventId) const -> lager::reader< Event >
 Get one message by the event id. More...
 
auto localEcho (lager::reader< std::string > txnId) const -> lager::reader< LocalEchoDesc >
 Get one local echo by the txnId. More...
 
auto heroMemberEvents () const -> lager::reader< immer::flex_vector< Event >>
 Get the member events of heroes this room. More...
 
auto heroDisplayNames () const -> lager::reader< immer::flex_vector< std::string >>
 Get the member events of heroes this room. More...
 
auto nameOpt () const -> lager::reader< std::optional< std::string >>
 Get the name of this room. More...
 
auto name () const -> lager::reader< std::string >
 Get the name of this room. More...
 
auto avatarMxcUri () const -> lager::reader< std::string >
 Get the avatar mxc uri of this room. More...
 
auto members () const -> lager::reader< immer::flex_vector< std::string >>
 Get the list of joined member ids. More...
 
auto invitedMembers () const -> lager::reader< immer::flex_vector< std::string >>
 Get the list of invited member ids. More...
 
auto knockedMembers () const -> lager::reader< immer::flex_vector< std::string >>
 Get the list of knocked member ids. More...
 
auto leftMembers () const -> lager::reader< immer::flex_vector< std::string >>
 Get the list of left member ids. More...
 
auto bannedMembers () const -> lager::reader< immer::flex_vector< std::string >>
 Get the list of banned member ids. More...
 
auto joinedMemberEvents () const -> lager::reader< EventList >
 Get the list of joined member events. More...
 
auto invitedMemberEvents () const -> lager::reader< EventList >
 Get the list of invited member events. More...
 
auto knockedMemberEvents () const -> lager::reader< EventList >
 Get the list of knocked member events. More...
 
auto leftMemberEvents () const -> lager::reader< EventList >
 Get the list of left member events. More...
 
auto bannedMemberEvents () const -> lager::reader< EventList >
 Get the list of banned member events. More...
 
auto memberEventByCursor (lager::reader< std::string > userId) const -> lager::reader< Event >
 Get the member event for userId. More...
 
auto memberEventFor (std::string userId) const -> lager::reader< Event >
 Get the member event for userId. More...
 
lager::reader< bool > encrypted () const
 Get whether this room is encrypted. More...
 
 KAZV_WRAP_ATTR (RoomModel, roomCursor(), roomId)
 
 KAZV_WRAP_ATTR (RoomModel, roomCursor(), membership)
 
 KAZV_WRAP_ATTR (RoomModel, roomCursor(), localDraft)
 
 KAZV_WRAP_ATTR (RoomModel, roomCursor(), membersFullyLoaded)
 
auto localReadMarker () const -> lager::reader< std::string >
 Get the local read marker in this room. More...
 
auto heroIds () const -> lager::reader< immer::flex_vector< std::string >>
 Get the ids of the heroes of the room. More...
 
auto joinedMemberCount () const -> lager::reader< std::size_t >
 Get the joined member count of this room. More...
 
auto invitedMemberCount () const -> lager::reader< std::size_t >
 Get the invited member count of this room. More...
 
PromiseT setLocalDraft (std::string localDraft) const
 Set local draft for this room. More...
 
PromiseT sendMessage (Event msg) const
 Send an event to this room. More...
 
PromiseT sendTextMessage (std::string text) const
 Send a text message to this room. More...
 
PromiseT resendMessage (std::string txnId) const
 Resend an event to this room. More...
 
PromiseT redactEvent (std::string eventId, std::optional< std::string > reason) const
 Redact an event. More...
 
PromiseT sendPendingKeyEvent (std::string txnId) const
 Send one pending key event in this room. More...
 
PromiseT sendAllPendingKeyEvents () const
 Send all pending key events in this room. More...
 
PromiseT refreshRoomState () const
 Get the full state of this room. More...
 
PromiseT getStateEvent (std::string type, std::string stateKey) const
 Get one state event with type and stateKey . More...
 
PromiseT sendStateEvent (Event state) const
 Send a state event to this room. More...
 
PromiseT setName (std::string name) const
 Set the room name. More...
 
auto topic () const
 
PromiseT setTopic (std::string topic) const
 Set the room topic. More...
 
PromiseT invite (std::string userId) const
 Invite a user to this room. More...
 
auto ephemeralEvents () const
 
auto ephemeralOpt (std::string type) const
 
auto ephemeral (std::string type) const
 
auto typingUsers () const -> lager::reader< immer::flex_vector< std::string >>
 Get the ids of all typing users in this room. More...
 
auto typingMemberEvents () const -> lager::reader< EventList >
 Get the member events of all typing users in this room. More...
 
PromiseT setTyping (bool typing, std::optional< int > timeoutMs) const
 Set the typing status of the current user in this room. More...
 
auto accountDataEvents () const
 
auto accountDataOpt (std::string type) const
 
auto accountData (std::string type) const
 
auto readMarker () const
 
PromiseT setAccountData (Event accountDataEvent) const
 Set the account data for this room. More...
 
auto tags () const -> lager::reader< immer::map< std::string, double >>
 Get the tags of the current room. More...
 
PromiseT addOrSetTag (std::string tagId, std::optional< double > order=std::nullopt) const
 Add or set a tag to this room. More...
 
PromiseT removeTag (std::string tagId) const
 Remove a tag from this room. More...
 
PromiseT leave () const
 Leave this room. More...
 
PromiseT forget () const
 Forget this room. More...
 
PromiseT kick (std::string userId, std::optional< std::string > reason=std::nullopt) const
 Kick a user from this room. More...
 
PromiseT ban (std::string userId, std::optional< std::string > reason=std::nullopt) const
 Ban a user from this room. More...
 
PromiseT unban (std::string userId) const
 Unban a user from this room. More...
 
auto avatar () const
 
auto pinnedEvents () const -> lager::reader< immer::flex_vector< std::string >>
 Get pinned events of this room. More...
 
PromiseT setPinnedEvents (immer::flex_vector< std::string > eventIds) const
 Set pinned events of this room. More...
 
PromiseT pinEvents (immer::flex_vector< std::string > eventIds) const
 Add eventIds to the pinned events of this room. More...
 
PromiseT unpinEvents (immer::flex_vector< std::string > eventIds) const
 Remove eventIds from the pinned events of this room. More...
 
lager::reader< immer::map< std::string, std::string > > timelineGaps () const
 Get the Gaps in the timeline for this room. More...
 
PromiseT paginateBackFromEvent (std::string eventId) const
 Try to paginate back from eventId. More...
 
auto localEchoes () const -> lager::reader< immer::flex_vector< LocalEchoDesc >>
 Get the list of local echoes in this room. More...
 
PromiseT removeLocalEcho (std::string txnId) const
 Remove a local echo from this room. More...
 
auto pendingRoomKeyEvents () const -> lager::reader< immer::flex_vector< PendingRoomKeyEvent >>
 Get the list of pending room key events in this room. More...
 
auto powerLevels () const -> lager::reader< PowerLevelsDesc >
 Get the power levels of this room. More...
 
auto relatedEvents (lager::reader< std::string > eventId, std::string relType) const -> lager::reader< EventList >
 Get a list of child events of a specified event. More...
 
auto eventReaders (lager::reader< std::string > eventId) const -> lager::reader< immer::flex_vector< EventReader >>
 Get a list of read receipts of some event in this room. More...
 
PromiseT postReceipt (std::string eventId) const
 Post a read receipt for this room. More...
 
auto unreadNotificationEventIds () const -> lager::reader< immer::flex_vector< std::string >>
 Get a list of event ids of unread notifications. More...
 

Detailed Description

Represent a Matrix room.

This class has the same constraints as Client.

Member Typedef Documentation

◆ ContextT

◆ DepsT

◆ PromiseT

Constructor & Destructor Documentation

◆ Room() [1/3]

Kazv::Room::Room ( lager::reader< SdkModel sdk,
lager::reader< std::string >  roomId,
ContextT  ctx 
)

Constructor.

Construct the room with roomId .

sdk and roomId must be cursors in the same thread.

The constructed room will be in the same thread as sdk and roomId.

Warning
Do not use this directly. Use Client::room() and Client::roomBycursor() instead.

◆ Room() [2/3]

Kazv::Room::Room ( lager::reader< SdkModel sdk,
lager::reader< std::string >  roomId,
ContextT  ctx,
DepsT  deps 
)

Constructor.

Construct the room with roomId and with Deps support.

sdk and roomId must be cursors in the same thread.

The constructed room will be in the same thread as sdk and roomId.

Warning
Do not use this directly. Use Client::room() and Client::roomBycursor() instead.

◆ Room() [3/3]

Kazv::Room::Room ( InEventLoopTag  ,
std::string  roomId,
ContextT  ctx,
DepsT  deps 
)

Construct a Room in the same thread as the event loop.

The constructed Room is not constructed from a cursor, and thus copying-constructing from that is thread-safe as long as each thread calls with different objects.

this must have Deps support.

Warning
Do not use this directly. Use Client::room() and Client::roomBycursor() instead.

Member Function Documentation

◆ accountData()

auto Kazv::Room::accountData ( std::string  type) const
inline

◆ accountDataEvents()

auto Kazv::Room::accountDataEvents ( ) const
inline

◆ accountDataOpt()

auto Kazv::Room::accountDataOpt ( std::string  type) const
inline

◆ addOrSetTag()

auto Kazv::Room::addOrSetTag ( std::string  tagId,
std::optional< double >  order = std::nullopt 
) const

Add or set a tag to this room.

Parameters
tagIdThe tag id to add or set.
orderThe order to specify.
Returns
A Promise that resolves when the tag has been set, or when there is an error.

◆ avatar()

auto Kazv::Room::avatar ( ) const
inline

◆ avatarMxcUri()

auto Kazv::Room::avatarMxcUri ( ) const -> lager::reader<std::string>

Get the avatar mxc uri of this room.

Returns
A lager::reader containing the mxc uri of this room.

◆ ban()

auto Kazv::Room::ban ( std::string  userId,
std::optional< std::string >  reason = std::nullopt 
) const

Ban a user from this room.

You must have enough power levels in this room to do so.

Parameters
userIdThe id of the user that will be banned.
reasonThe reason to explain this ban.
Returns
A Promise that resolves when the ban is done, or when there is an error.

◆ bannedMemberEvents()

auto Kazv::Room::bannedMemberEvents ( ) const -> lager::reader<EventList>

Get the list of banned member events.

Returns
A lager::reader containing an EventList of the banned members' events.

◆ bannedMembers()

auto Kazv::Room::bannedMembers ( ) const -> lager::reader<immer::flex_vector<std::string>>

Get the list of banned member ids.

Returns
A lager::reader containing an RangeT of the banned members' id.

◆ encrypted()

lager::reader< bool > Kazv::Room::encrypted ( ) const

Get whether this room is encrypted.

The encryption status is changed to true if the client receives a state event that turns on encryption. If that state event is removed later, the status will not be changed.

Returns
A lager::reader<bool> that contains whether this room is encrypted.

◆ ephemeral()

auto Kazv::Room::ephemeral ( std::string  type) const
inline

◆ ephemeralEvents()

auto Kazv::Room::ephemeralEvents ( ) const
inline

◆ ephemeralOpt()

auto Kazv::Room::ephemeralOpt ( std::string  type) const
inline

◆ eventReaders()

auto Kazv::Room::eventReaders ( lager::reader< std::string >  eventId) const -> lager::reader<immer::flex_vector<EventReader>>

Get a list of read receipts of some event in this room.

Parameters
eventIdThe id of the event.
Returns
A lager::reader of a RangeT of matrix id and timestamp of receipts of the event.

◆ forget()

auto Kazv::Room::forget ( ) const

Forget this room.

One can only forget a room when they have already left it.

Returns
A Promise that resolves when the room has been forgot, or when there is an error.

◆ getStateEvent()

auto Kazv::Room::getStateEvent ( std::string  type,
std::string  stateKey 
) const

Get one state event with type and stateKey .

This method will update the Client as needed.

After the returned Promise resolves successfully, state({type,stateKey}) will contain the fetched state event.

Returns
A Promise that resolves when the state event has been fetched, or when there is an error.

◆ heroDisplayNames()

auto Kazv::Room::heroDisplayNames ( ) const -> lager::reader<immer::flex_vector<std::string>>

Get the member events of heroes this room.

Returns
a lager::reader of a RangeT of std::string containing the member events.

◆ heroIds()

auto Kazv::Room::heroIds ( ) const -> lager::reader<immer::flex_vector<std::string>>

Get the ids of the heroes of the room.

Returns
a lager::reader of a RangeT<std::string> containing the ids of the heroes of the room.

◆ heroMemberEvents()

auto Kazv::Room::heroMemberEvents ( ) const -> lager::reader<immer::flex_vector<Event>>

Get the member events of heroes this room.

Returns
a lager::reader of a RangeT of Event containing the member events.

◆ invite()

auto Kazv::Room::invite ( std::string  userId) const

Invite a user to this room.

Parameters
userIdThe user id for the user to invite.
Returns
A Promise that resolves when the state event for the invite has been sent, or when there is an error.

◆ invitedMemberCount()

auto Kazv::Room::invitedMemberCount ( ) const -> lager::reader<std::size_t>

Get the invited member count of this room.

Returns
A lager::reader of std::size_t containing the invited member count for this room.

◆ invitedMemberEvents()

auto Kazv::Room::invitedMemberEvents ( ) const -> lager::reader<EventList>

Get the list of invited member events.

Returns
A lager::reader containing an EventList of the invited members' events.

◆ invitedMembers()

auto Kazv::Room::invitedMembers ( ) const -> lager::reader<immer::flex_vector<std::string>>

Get the list of invited member ids.

Returns
A lager::reader containing an RangeT of the invited members' ids.

◆ inviteState()

auto Kazv::Room::inviteState ( ) const -> lager::reader<immer::map<KeyOfState, Event>>

Get the invite_state of this room.

Returns
A lager::reader containing a map from KeyOfState to the event.

◆ joinedMemberCount()

auto Kazv::Room::joinedMemberCount ( ) const -> lager::reader<std::size_t>

Get the joined member count of this room.

Returns
A lager::reader of std::size_t containing the joined member count for this room.

◆ joinedMemberEvents()

auto Kazv::Room::joinedMemberEvents ( ) const -> lager::reader<EventList>

Get the list of joined member events.

Returns
A lager::reader containing an EventList of the joined members' events.

◆ KAZV_WRAP_ATTR() [1/4]

Kazv::Room::KAZV_WRAP_ATTR ( RoomModel  ,
roomCursor()  ,
localDraft   
)

◆ KAZV_WRAP_ATTR() [2/4]

Kazv::Room::KAZV_WRAP_ATTR ( RoomModel  ,
roomCursor()  ,
membersFullyLoaded   
)

◆ KAZV_WRAP_ATTR() [3/4]

Kazv::Room::KAZV_WRAP_ATTR ( RoomModel  ,
roomCursor()  ,
membership   
)

◆ KAZV_WRAP_ATTR() [4/4]

Kazv::Room::KAZV_WRAP_ATTR ( RoomModel  ,
roomCursor()  ,
roomId   
)

◆ kick()

auto Kazv::Room::kick ( std::string  userId,
std::optional< std::string >  reason = std::nullopt 
) const

Kick a user from this room.

You must have enough power levels in this room to do so.

Parameters
userIdThe id of the user that will be kicked.
reasonThe reason to explain this kick.
Returns
A Promise that resolves when the kick is done, or when there is an error.

◆ knockedMemberEvents()

auto Kazv::Room::knockedMemberEvents ( ) const -> lager::reader<EventList>

Get the list of knocked member events.

Returns
A lager::reader containing an EventList of the knocked members' events.

◆ knockedMembers()

auto Kazv::Room::knockedMembers ( ) const -> lager::reader<immer::flex_vector<std::string>>

Get the list of knocked member ids.

Returns
A lager::reader containing an RangeT of the knocked members' ids.

◆ leave()

auto Kazv::Room::leave ( ) const

Leave this room.

Returns
A Promise that resolves when the state event for the leaving has been sent, or when there is an error.

◆ leftMemberEvents()

auto Kazv::Room::leftMemberEvents ( ) const -> lager::reader<EventList>

Get the list of left member events.

Returns
A lager::reader containing an EventList of the left members' events.

◆ leftMembers()

auto Kazv::Room::leftMembers ( ) const -> lager::reader<immer::flex_vector<std::string>>

Get the list of left member ids.

Returns
A lager::reader containing an RangeT of the left members' ids.

◆ localEcho()

auto Kazv::Room::localEcho ( lager::reader< std::string >  txnId) const -> lager::reader<LocalEchoDesc>

Get one local echo by the txnId.

Parameters
Alager::reader of the txnId.
Returns
A lager::reader of the local echo.

◆ localEchoes()

auto Kazv::Room::localEchoes ( ) const -> lager::reader<immer::flex_vector<LocalEchoDesc>>

Get the list of local echoes in this room.

Returns
A lager::reader that contains the list of all local echoes in the room. The event type will always be m.room.message and event id will not be meaningful.

◆ localReadMarker()

auto Kazv::Room::localReadMarker ( ) const -> lager::reader<std::string>

Get the local read marker in this room.

Returns
a lager::reader of a std::string of the local read marker.

◆ memberEventByCursor()

auto Kazv::Room::memberEventByCursor ( lager::reader< std::string >  userId) const -> lager::reader<Event>

Get the member event for userId.

If membership of the current user is Invite, it prefers the event in inviteState to the one in stateEvents.

Returns
A lager::reader containing the state event.

◆ memberEventFor()

auto Kazv::Room::memberEventFor ( std::string  userId) const -> lager::reader<Event>

Get the member event for userId.

If membership of the current user is Invite, it prefers the event in inviteState to the one in stateEvents.

Returns
A lager::reader containing the state event.

◆ members()

auto Kazv::Room::members ( ) const -> lager::reader<immer::flex_vector<std::string>>

Get the list of joined member ids.

Returns
A lager::reader containing an RangeT of the joined members' ids.

◆ message()

auto Kazv::Room::message ( lager::reader< std::string >  eventId) const -> lager::reader<Event>

Get one message by the event id.

Parameters
Alager::reader of the event id.
Returns
A lager::reader of the event.

◆ messagesMap()

auto Kazv::Room::messagesMap ( ) const -> lager::reader<immer::map<std::string, Event>>

Get a map from event ids to events.

It takes constant time for the cursor to be updated.

Returns
A lager::reader of a map for all timeline events.

◆ name()

auto Kazv::Room::name ( ) const -> lager::reader<std::string>

Get the name of this room.

If there is a m.room.name state event, the name in it is used. If there is none, the returned cursor will hold a placeholder string.

Returns
a lager::reader of an std::string.

◆ nameOpt()

auto Kazv::Room::nameOpt ( ) const -> lager::reader<std::optional<std::string>>

Get the name of this room.

If there is a m.room.name state event, the name in it is used. If there is none, the returned cursor will hold std::nullopt.

Returns
a lager::reader of an optional std::string.

◆ paginateBackFromEvent()

auto Kazv::Room::paginateBackFromEvent ( std::string  eventId) const

Try to paginate back from eventId.

Parameters
eventIdAn event id that is in the key of +timelineGaps().
Returns
A Promise that resolves when the pagination is successful, or when there is an error. If it is successful, +timelineGaps() will no longer contain eventId as key, and timeline() will contain the events before eventId in the full event chain on the homeserver. If eventId is not in +timelineGaps(), it is considered to be failed.

◆ pendingRoomKeyEvents()

auto Kazv::Room::pendingRoomKeyEvents ( ) const -> lager::reader<immer::flex_vector<PendingRoomKeyEvent>>

Get the list of pending room key events in this room.

Returns
A lager::reader that contains the list of all pending room key events in the room. The event type will always be m.room.encrypted and event id will not be meaningful.

◆ pinEvents()

auto Kazv::Room::pinEvents ( immer::flex_vector< std::string >  eventIds) const

Add eventIds to the pinned events of this room.

Parameters
eventIdsThe ids of events you want to add to the pinned events.
Returns
A Promise that resolves when the state event for the pinned events change has been sent, or when there is an error.

◆ pinnedEvents()

auto Kazv::Room::pinnedEvents ( ) const -> lager::reader<immer::flex_vector<std::string>>

Get pinned events of this room.

Returns
A lager::reader of RangeT of the pinned event ids.

◆ postReceipt()

auto Kazv::Room::postReceipt ( std::string  eventId) const

Post a read receipt for this room.

Parameters
eventIdThe event id the user has read up to.
Returns
A Promise that resolves when the read receipt is sent.

◆ powerLevels()

auto Kazv::Room::powerLevels ( ) const -> lager::reader<PowerLevelsDesc>

Get the power levels of this room.

Returns
A lager::reader that contains a PowerLevelDesc describing the power levels of this room.

◆ readMarker()

auto Kazv::Room::readMarker ( ) const
inline

◆ redactEvent()

auto Kazv::Room::redactEvent ( std::string  eventId,
std::optional< std::string >  reason 
) const

Redact an event.

Parameters
eventIdThe event id of the event you want to redact
reasonThe reason of redaction
Returns
A Promise that resolves when the event has been sent, or when there is an error.

◆ refreshRoomState()

auto Kazv::Room::refreshRoomState ( ) const

Get the full state of this room.

This method will update the Client as needed.

After the returned Promise resolves successfully, stateEvents() will contain the fetched state.

Returns
A Promise that resolves when the room state has been fetched, or when there is an error.

◆ relatedEvents()

auto Kazv::Room::relatedEvents ( lager::reader< std::string >  eventId,
std::string  relType 
) const -> lager::reader<EventList>

Get a list of child events of a specified event.

Parameters
eventIdThe id of the event.
relTypeThe type of the relationship.
Returns
A lager::reader of a RangeT of events that are related to the event via relType. It is sorted in the same order as the timeline.

◆ removeLocalEcho()

auto Kazv::Room::removeLocalEcho ( std::string  txnId) const

Remove a local echo from this room.

Parameters
txnIdThe transaction id associated with that local echo.
Returns
A Promise that resolves when the local echo is removed.

◆ removeTag()

auto Kazv::Room::removeTag ( std::string  tagId) const

Remove a tag from this room.

Parameters
tagIdThe tag id to remove.
Returns
A Promise that resolves when the tag has been removed, or when there is an error.

◆ resendMessage()

auto Kazv::Room::resendMessage ( std::string  txnId) const

Resend an event to this room.

Parameters
txnIdThe transaction id of the unsent message
Returns
A Promise that resolves when the event has been sent, or when there is an error.

◆ sendAllPendingKeyEvents()

auto Kazv::Room::sendAllPendingKeyEvents ( ) const

Send all pending key events in this room.

Returns
A Promise that resolves when all events has been sent, or when there is an error.

◆ sendMessage()

auto Kazv::Room::sendMessage ( Event  msg) const

Send an event to this room.

Parameters
msgThe message to send
Returns
A Promise that resolves when the event has been sent, or when there is an error.

◆ sendPendingKeyEvent()

auto Kazv::Room::sendPendingKeyEvent ( std::string  txnId) const

Send one pending key event in this room.

Parameters
txnIdThe transaction id of the pending key event
Returns
A Promise that resolves when the event has been sent, or when there is an error.

◆ sendStateEvent()

auto Kazv::Room::sendStateEvent ( Event  state) const

Send a state event to this room.

Parameters
stateThe state event to send.
Returns
A Promise that resolves when the state event has been sent, or when there is an error.

◆ sendTextMessage()

auto Kazv::Room::sendTextMessage ( std::string  text) const

Send a text message to this room.

Parameters
textThe text
Returns
A Promise that resolves when the text message has been sent, or when there is an error.

◆ setAccountData()

auto Kazv::Room::setAccountData ( Event  accountDataEvent) const

Set the account data for this room.

Returns
A Promise that resolves when the account data has been set, or when there is an error.

◆ setLocalDraft()

auto Kazv::Room::setLocalDraft ( std::string  localDraft) const

Set local draft for this room.

After the returned Promise is resolved, localDraft() will contain localDraft .

Parameters
localDraftThe local draft to send.
Returns
A Promise that resolves when the local draft has been set, or when there is an error.

◆ setName()

auto Kazv::Room::setName ( std::string  name) const

Set the room name.

Parameters
nameThe new name for this room.
Returns
A Promise that resolves when the state event for the name change has been sent, or when there is an error.

◆ setPinnedEvents()

auto Kazv::Room::setPinnedEvents ( immer::flex_vector< std::string >  eventIds) const

Set pinned events of this room.

Parameters
eventIdsThe event ids of the new pinned events
Returns
A Promise that resolves when the state event for the pinned events change has been sent, or when there is an error.

◆ setTopic()

auto Kazv::Room::setTopic ( std::string  topic) const

Set the room topic.

Parameters
topicThe new topic for this room.
Returns
A Promise that resolves when the state event for the topic change has been sent, or when there is an error.

◆ setTyping()

auto Kazv::Room::setTyping ( bool  typing,
std::optional< int >  timeoutMs 
) const

Set the typing status of the current user in this room.

Parameters
typingWhether the user is now typing.
timeoutMsHow long this typing status should last, in milliseconds.
Returns
A Promise that resolves when the typing status has been sent, or when there is an error.

◆ state()

auto Kazv::Room::state ( KeyOfState  k) const
inline

◆ stateEvents()

auto Kazv::Room::stateEvents ( ) const
inline

◆ stateOpt()

auto Kazv::Room::stateOpt ( KeyOfState  k) const
inline

◆ tags()

auto Kazv::Room::tags ( ) const -> lager::reader<immer::map<std::string, double>>

Get the tags of the current room.

Returns
A lager::reader of a map from tag id of this room to the corresponding order.

◆ timelineEventIds()

auto Kazv::Room::timelineEventIds ( ) const -> lager::reader<immer::flex_vector<std::string>>

Get the timeline event ids of this room in ascending timestamp order.

It takes constant time for the cursor to be updated.

Returns
A lager::reader of a RangeT of event ids.

◆ timelineEvents()

auto Kazv::Room::timelineEvents ( ) const -> lager::reader<immer::flex_vector<Event>>

Get a list of timeline events in this room.

It takes O(timeline.size()) time for the cursor to be updated.

Returns
A lager::reader<RangeT<Event>> of timeline events from the oldest to the latest.

◆ timelineGaps()

auto Kazv::Room::timelineGaps ( ) const

Get the Gaps in the timeline for this room.

Any key of the map in the returned reader can be send as an argument of paginateBackFromEvent() to try to fill the Gap at that event.

Returns
A lager::reader that contains an evnetId-to-prevBatch map.

◆ toEventLoop()

Room Kazv::Room::toEventLoop ( ) const

Return a Room that represents the room currently represented by this, but suitable for use in the event loop of the context.

This function can only be called from the thread where this belongs.

Example:

auto ctx = sdk.context();
auto client = sdk.clientFromSecondaryRoot(sr);
auto room = client.room("!room-id:domain.name");
room.sendTextMessage("test")
.then([r=room.toEventLoop(), ctx](auto &&st) {
if (!st) {
std::cerr << "Cannot send message" << std::endl;
return ctx.createResolvedPromise(st);
}
return r.sendTextMessage("follow-up");
});
See also
Sdk::clientFromSecondaryRoot , Client::room

◆ topic()

auto Kazv::Room::topic ( ) const
inline

◆ typingMemberEvents()

auto Kazv::Room::typingMemberEvents ( ) const -> lager::reader<EventList>

Get the member events of all typing users in this room.

Returns
A lager::reader of an EventList of member events of all typing users.

◆ typingUsers()

auto Kazv::Room::typingUsers ( ) const -> lager::reader<immer::flex_vector<std::string>>

Get the ids of all typing users in this room.

Returns
A lager::reader of an RangeT of std::string of ids of all typing users.

◆ unban()

auto Kazv::Room::unban ( std::string  userId) const

Unban a user from this room.

You must have enough power levels in this room to do so.

Parameters
userIdThe id of the user that will be unbanned.
Returns
A Promise that resolves when the unban is done, or when there is an error.

◆ unpinEvents()

auto Kazv::Room::unpinEvents ( immer::flex_vector< std::string >  eventIds) const

Remove eventIds from the pinned events of this room.

Parameters
eventIdsThe ids of events you want to remove from the pinned events.
Returns
A Promise that resolves when the state event for the pinned events change has been sent, or when there is an error.

◆ unreadNotificationEventIds()

auto Kazv::Room::unreadNotificationEventIds ( ) const -> lager::reader<immer::flex_vector<std::string>>

Get a list of event ids of unread notifications.

Returns
A lager::reader of a RangeT of event ids that has an unread notification.

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