libkazv
Kazv::Api::SyncJob Class Reference

Synchronise the client's state and receive new messages. More...

#include <sync.hpp>

Inheritance diagram for Kazv::Api::SyncJob:
Collaboration diagram for Kazv::Api::SyncJob:

Classes

struct  InvitedRoom
 Synchronise the client's state with the latest state on the server. More...
 
struct  InviteState
 The stripped state of a room that the user has been invited to. More...
 
class  JobResponse
 
struct  JoinedRoom
 Synchronise the client's state with the latest state on the server. More...
 
struct  KnockedRoom
 Synchronise the client's state with the latest state on the server. More...
 
struct  KnockState
 The stripped state of a room that the user has knocked upon. More...
 
struct  LeftRoom
 Synchronise the client's state with the latest state on the server. More...
 
struct  Rooms
 Updates to rooms. More...
 
struct  RoomSummary
 Information about the room which clients may need to correctly render it to users. More...
 
struct  UnreadNotificationCounts
 Counts of unread notifications for this room. More...
 

Public Member Functions

 SyncJob (std::string serverUrl, std::string _accessToken, std::optional< std::string > filter=std::nullopt, std::optional< std::string > since=std::nullopt, std::optional< bool > fullState=std::nullopt, std::optional< std::string > setPresence=std::nullopt, std::optional< int > timeout=std::nullopt)
 Synchronise the client's state and receive new messages. More...
 
SyncJob withData (JsonWrap j) &&
 
SyncJob withData (JsonWrap j) const &
 
- Public Member Functions inherited from Kazv::BaseJob
 BaseJob (std::string serverUrl, std::string requestUrl, Method method, std::string jobId, std::string token={}, ReturnType returnType=ReturnType::Json, Body body=EmptyBody{}, Query query={}, Header header={}, std::optional< FileDesc > responseFile=std::nullopt)
 
 ~BaseJob ()
 
bool shouldReturnJson () const
 
std::string url () const
 
Body requestBody () const
 
Header requestHeader () const
 
ReturnType returnType () const
 
Query requestQuery () const
 returns the non-encoded query as an array of pairs More...
 
Method requestMethod () const
 
Response genResponse (Response r) const
 
BaseJob withData (JsonWrap j) &&
 
BaseJob withData (JsonWrap j) const &
 
BaseJob withQueue (std::string id, JobQueuePolicy policy=AlwaysContinue) &&
 
BaseJob withQueue (std::string id, JobQueuePolicy policy=AlwaysContinue) const &
 
json dataJson (const std::string &key) const
 
std::string dataStr (const std::string &key) const
 
std::string jobId () const
 
std::optional< std::string > queueId () const
 
JobQueuePolicy queuePolicy () const
 
std::optional< FileDescresponseFile () const
 

Static Public Member Functions

static constexpr auto needsAuth ()
 
static BaseJob::Query buildQuery (std::optional< std::string > filter, std::optional< std::string > since, std::optional< bool > fullState, std::optional< std::string > setPresence, std::optional< int > timeout)
 
static BaseJob::Body buildBody (std::optional< std::string > filter, std::optional< std::string > since, std::optional< bool > fullState, std::optional< std::string > setPresence, std::optional< int > timeout)
 
- Static Public Member Functions inherited from Kazv::BaseJob
static bool contentTypeMatches (immer::array< std::string > expected, std::string actual)
 

Additional Inherited Members

- Public Types inherited from Kazv::BaseJob
enum  ReturnType { Json , File }
 
using Method = std::variant< Get, Post, Put, Delete >
 
using Body = ::Kazv::Body
 
using BytesBody = ::Kazv::BytesBody
 
using JsonBody = ::Kazv::JsonBody
 
using EmptyBody = ::Kazv::EmptyBody
 
using Header = ::Kazv::Header
 
using Response = ::Kazv::Response
 
- Static Public Attributes inherited from Kazv::BaseJob
static Get GET {}
 
static Post POST {}
 
static Put PUT {}
 
static Delete DELETE {}
 
- Protected Member Functions inherited from Kazv::BaseJob
void attachData (JsonWrap data)
 

Detailed Description

Synchronise the client's state and receive new messages.

Synchronise the client's state with the latest state on the server. Clients use this API when they first log in to get an initial snapshot of the state on the server, and then continue to call this API to get incremental deltas to the state, and to receive new messages.

Note: This endpoint supports lazy-loading. See Filtering for more information. Lazy-loading members is only supported on a StateFilter for this endpoint. When lazy-loading is enabled, servers MUST include the syncing user's own membership event when they join a room, or when the full state of rooms is requested, to aid discovering the user's avatar & displayname.

Further, like other members, the user's own membership event is eligible for being considered redundant by the server. When a sync is limited, the server MUST return membership events for events in the gap (between since and the start of the returned timeline), regardless as to whether or not they are redundant. This ensures that joins/leaves and profile changes which occur during the gap are not lost.

Note that the default behaviour of state is to include all membership events, alongside other state, when lazy-loading is not enabled.

Constructor & Destructor Documentation

◆ SyncJob()

Kazv::Api::SyncJob::SyncJob ( std::string  serverUrl,
std::string  _accessToken,
std::optional< std::string >  filter = std::nullopt,
std::optional< std::string >  since = std::nullopt,
std::optional< bool >  fullState = std::nullopt,
std::optional< std::string >  setPresence = std::nullopt,
std::optional< int >  timeout = std::nullopt 
)
explicit

Synchronise the client's state and receive new messages.

Parameters
filterThe ID of a filter created using the filter API or a filter JSON object encoded as a string. The server will detect whether it is an ID or a JSON object by whether the first character is a "{" open brace. Passing the JSON inline is best suited to one off requests. Creating a filter using the filter API is recommended for clients that reuse the same filter multiple times, for example in long poll requests.

See Filtering for more information.

Parameters
sinceA point in time to continue a sync from. This should be the next_batch token returned by an earlier call to this endpoint.
fullStateControls whether to include the full state for all rooms the user is a member of.

If this is set to true, then all state events will be returned, even if since is non-empty. The timeline will still be limited by the since parameter. In this case, the timeout parameter will be ignored and the query will return immediately, possibly with an empty timeline.

If false, and since is non-empty, only state which has changed since the point indicated by since will be returned.

By default, this is false.

Parameters
setPresenceControls whether the client is automatically marked as online by polling this API. If this parameter is omitted then the client is automatically marked as online when it uses this API. Otherwise if the parameter is set to "offline" then the client is not marked as being online when it uses this API. When set to "unavailable", the client is marked as being idle.
timeoutThe maximum time to wait, in milliseconds, before returning this request. If no events (or other data) become available before this time elapses, the server will return a response with empty fields.

By default, this is 0, so the server will return immediately even if the response is empty.

Member Function Documentation

◆ buildBody()

BaseJob::Body Kazv::Api::SyncJob::buildBody ( std::optional< std::string >  filter,
std::optional< std::string >  since,
std::optional< bool >  fullState,
std::optional< std::string >  setPresence,
std::optional< int >  timeout 
)
static

◆ buildQuery()

BaseJob::Query Kazv::Api::SyncJob::buildQuery ( std::optional< std::string >  filter,
std::optional< std::string >  since,
std::optional< bool >  fullState,
std::optional< std::string >  setPresence,
std::optional< int >  timeout 
)
static

◆ needsAuth()

static constexpr auto Kazv::Api::SyncJob::needsAuth ( )
inlinestaticconstexpr

◆ withData() [1/2]

SyncJob Kazv::Api::SyncJob::withData ( JsonWrap  j) &&

◆ withData() [2/2]

SyncJob Kazv::Api::SyncJob::withData ( JsonWrap  j) const &

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