provide roomLimited callback
This commit is contained in:
parent
05385723ee
commit
d6f56e8b2d
2 changed files with 14 additions and 0 deletions
|
@ -40,6 +40,7 @@ enum struct RequestError : u8 {
|
||||||
|
|
||||||
typedef void (*eventCallback)(std::string roomId, json_t* event);
|
typedef void (*eventCallback)(std::string roomId, json_t* event);
|
||||||
typedef void (*roomInfoCallback)(std::string roomId, RoomInfo info);
|
typedef void (*roomInfoCallback)(std::string roomId, RoomInfo info);
|
||||||
|
typedef void (*roomLimitedCallback)(std::string roomId, std::string prevBatch);
|
||||||
|
|
||||||
class Client {
|
class Client {
|
||||||
private:
|
private:
|
||||||
|
@ -58,6 +59,7 @@ public:
|
||||||
eventCallback leaveRoom = NULL;
|
eventCallback leaveRoom = NULL;
|
||||||
eventCallback inviteRoom = NULL;
|
eventCallback inviteRoom = NULL;
|
||||||
roomInfoCallback roomInfo = NULL;
|
roomInfoCallback roomInfo = NULL;
|
||||||
|
roomLimitedCallback roomLimited = NULL;
|
||||||
} callbacks;
|
} callbacks;
|
||||||
void processSync(json_t* sync);
|
void processSync(json_t* sync);
|
||||||
void registerFilter();
|
void registerFilter();
|
||||||
|
@ -95,6 +97,7 @@ public:
|
||||||
void setLeaveRoomCallback(eventCallback cb);
|
void setLeaveRoomCallback(eventCallback cb);
|
||||||
void setInviteRoomCallback(eventCallback cb);
|
void setInviteRoomCallback(eventCallback cb);
|
||||||
void setRoomInfoCallback(roomInfoCallback cb);
|
void setRoomInfoCallback(roomInfoCallback cb);
|
||||||
|
void setRoomLimitedCallback(roomLimitedCallback cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
}; // namespace Matrix
|
}; // namespace Matrix
|
||||||
|
|
|
@ -404,6 +404,10 @@ void Client::setRoomInfoCallback(roomInfoCallback cb) {
|
||||||
callbacks.roomInfo = cb;
|
callbacks.roomInfo = cb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Client::setRoomLimitedCallback(roomLimitedCallback cb) {
|
||||||
|
callbacks.roomLimited = cb;
|
||||||
|
}
|
||||||
|
|
||||||
void Client::processSync(json_t* sync) {
|
void Client::processSync(json_t* sync) {
|
||||||
json_t* rooms = json_object_get(sync, "rooms");
|
json_t* rooms = json_object_get(sync, "rooms");
|
||||||
if (!rooms) {
|
if (!rooms) {
|
||||||
|
@ -558,6 +562,13 @@ void Client::processSync(json_t* sync) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
json_t* timeline = json_object_get(room, "timeline");
|
json_t* timeline = json_object_get(room, "timeline");
|
||||||
|
if (callbacks.roomLimited && timeline) {
|
||||||
|
json_t* limited = json_object_get(timeline, "limited");
|
||||||
|
const char* prevBatch = json_object_get_string_value(timeline, "prev_batch");
|
||||||
|
if (limited && prevBatch && json_typeof(limited) == JSON_TRUE) {
|
||||||
|
callbacks.roomLimited(roomId, prevBatch);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (callbacks.event && timeline) {
|
if (callbacks.event && timeline) {
|
||||||
json_t* events = json_object_get(timeline, "events");
|
json_t* events = json_object_get(timeline, "events");
|
||||||
if (events) {
|
if (events) {
|
||||||
|
|
Loading…
Reference in a new issue