aboutsummaryrefslogtreecommitdiff
path: root/lib/connection.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/connection.cpp')
-rw-r--r--lib/connection.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index cf3446ff..a1fbd903 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -730,7 +730,7 @@ User* Connection::user(const QString& userId)
}
if( d->userMap.contains(userId) )
return d->userMap.value(userId);
- auto* user = userFactory(this, userId);
+ auto* user = userFactory()(this, userId);
d->userMap.insert(userId, user);
emit newUser(user);
return user;
@@ -987,7 +987,7 @@ Room* Connection::provideRoom(const QString& id, JoinState joinState)
}
else
{
- room = roomFactory(this, id, joinState);
+ room = roomFactory()(this, id, joinState);
if (!room)
{
qCCritical(MAIN) << "Failed to create a room" << id;
@@ -1025,12 +1025,28 @@ Room* Connection::provideRoom(const QString& id, JoinState joinState)
return room;
}
-Connection::room_factory_t Connection::roomFactory =
- [](Connection* c, const QString& id, JoinState joinState)
- { return new Room(c, id, joinState); };
+void Connection::setRoomFactory(room_factory_t f)
+{
+ _roomFactory = std::move(f);
+}
+
+void Connection::setUserFactory(user_factory_t f)
+{
+ _userFactory = std::move(f);
+}
+
+room_factory_t Connection::roomFactory()
+{
+ return _roomFactory;
+}
+
+user_factory_t Connection::userFactory()
+{
+ return _userFactory;
+}
-Connection::user_factory_t Connection::userFactory =
- [](Connection* c, const QString& id) { return new User(id, c); };
+room_factory_t Connection::_roomFactory = defaultRoomFactory<>();
+user_factory_t Connection::_userFactory = defaultUserFactory<>();
QByteArray Connection::generateTxnId() const
{