mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-08 21:05:34 +08:00
Issue #15 Shared state unittest
This commit is contained in:
@@ -53,7 +53,7 @@ namespace BlackMisc
|
||||
virtual bool isConnected() const = 0;
|
||||
|
||||
//! Get a duplex object for the calling process.
|
||||
virtual std::pair<QSharedPointer<IDuplex>, QFuture<void>> getDuplex() = 0;
|
||||
virtual std::pair<QSharedPointer<IDuplex>, QFuture<void>> getDuplex(const CIdentifier &) = 0;
|
||||
|
||||
public slots:
|
||||
//! Create a duplex object for the identified process.
|
||||
|
||||
@@ -24,10 +24,10 @@ namespace BlackMisc
|
||||
if (server) { server->addObject(BLACKMISC_HUB_PATH, this); }
|
||||
}
|
||||
|
||||
std::pair<QSharedPointer<IDuplex>, QFuture<void>> CHub::getDuplex()
|
||||
std::pair<QSharedPointer<IDuplex>, QFuture<void>> CHub::getDuplex(const CIdentifier &identifier)
|
||||
{
|
||||
auto future = openDuplexAsync(CIdentifier::anonymous());
|
||||
return std::make_pair(m_clients.value(CIdentifier::anonymous()), future);
|
||||
auto future = openDuplexAsync(identifier);
|
||||
return std::make_pair(m_clients.value(identifier), future);
|
||||
}
|
||||
|
||||
bool CHub::openDuplex(const BlackMisc::CIdentifier &client)
|
||||
|
||||
@@ -48,8 +48,7 @@ namespace BlackMisc
|
||||
//! \name Interface implementations
|
||||
//! @{
|
||||
virtual bool isConnected() const override { return true; }
|
||||
virtual std::pair<QSharedPointer<IDuplex>, QFuture<void>> getDuplex() override;
|
||||
//! @}
|
||||
virtual std::pair<QSharedPointer<IDuplex>, QFuture<void>> getDuplex(const CIdentifier &) override;
|
||||
|
||||
public slots:
|
||||
//! \name Interface implementations
|
||||
|
||||
@@ -31,11 +31,11 @@ namespace BlackMisc
|
||||
return m_interface->isValid();
|
||||
}
|
||||
|
||||
std::pair<QSharedPointer<IDuplex>, QFuture<void>> CHubProxy::getDuplex()
|
||||
std::pair<QSharedPointer<IDuplex>, QFuture<void>> CHubProxy::getDuplex(const CIdentifier &identifier)
|
||||
{
|
||||
auto duplex = QSharedPointer<CDuplexProxy>::create(m_interface->connection(), m_service, this);
|
||||
connect(duplex.get(), &QObject::destroyed, this, [ = ] { closeDuplex(CIdentifier::anonymous()); });
|
||||
return std::make_pair(duplex, openDuplexAsync(CIdentifier::anonymous()));
|
||||
connect(duplex.get(), &QObject::destroyed, this, [ = ] { closeDuplex(identifier); });
|
||||
return std::make_pair(duplex, openDuplexAsync(identifier));
|
||||
}
|
||||
|
||||
bool CHubProxy::openDuplex(const CIdentifier& client)
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace BlackMisc
|
||||
//! \name Interface implementations
|
||||
//! @{
|
||||
virtual bool isConnected() const override;
|
||||
virtual std::pair<QSharedPointer<IDuplex>, QFuture<void>> getDuplex() override;
|
||||
virtual std::pair<QSharedPointer<IDuplex>, QFuture<void>> getDuplex(const CIdentifier &) override;
|
||||
//! @}
|
||||
|
||||
public slots:
|
||||
|
||||
Reference in New Issue
Block a user