Skip to content

Commit 3b71dbb

Browse files
committed
feat: add knockroom api
1 parent e20f13f commit 3b71dbb

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/connection.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,22 @@ JoinRoomJob* Connection::joinRoom(const QString& roomAlias,
11401140
return job;
11411141
}
11421142

1143+
KnockRoomJob* Connection::knockRoom(const QString& roomAlias,
1144+
const QStringList& serverNames,
1145+
const QString& reason)
1146+
{
1147+
auto* const job = callApi<KnockRoomJob>(roomAlias, serverNames, reason);
1148+
// Upon completion, ensure a room object is created in case it hasn't come
1149+
// with a sync yet. If the room object is not there, provideRoom() will
1150+
// create it in Join state. finished() is used here instead of success()
1151+
// to overtake clients that may add their own slots to finished().
1152+
connect(job, &BaseJob::finished, this, [this, job] {
1153+
if (job->status().good())
1154+
provideRoom(job->roomId());
1155+
});
1156+
return job;
1157+
}
1158+
11431159
LeaveRoomJob* Connection::leaveRoom(Room* room)
11441160
{
11451161
const auto& roomId = room->id();

lib/connection.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "util.h"
1111

1212
#include "csapi/create_room.h"
13+
#include "csapi/knocking.h"
1314
#include "csapi/login.h"
1415

1516
#include "events/accountdataevents.h"
@@ -657,6 +658,9 @@ public Q_SLOTS:
657658
virtual JoinRoomJob* joinRoom(const QString& roomAlias,
658659
const QStringList& serverNames = {});
659660

661+
virtual KnockRoomJob* knockRoom(const QString& roomAlias,
662+
const QStringList& serverNames = {},
663+
const QString& reason = {});
660664
//! \brief Send /forget to the server and delete room locally
661665
//!
662666
//! This method is in Connection, not in Room, since it's a

0 commit comments

Comments
 (0)