InspectorFrontendRouter.cpp [plain text]
#include "config.h"
#include "InspectorFrontendRouter.h"
#include "InspectorFrontendChannel.h"
#include <wtf/Assertions.h>
namespace Inspector {
Ref<FrontendRouter> FrontendRouter::create()
{
return adoptRef(*new FrontendRouter);
}
void FrontendRouter::connectFrontend(FrontendChannel* connection)
{
ASSERT_ARG(connection, connection);
if (m_connections.contains(connection)) {
ASSERT_NOT_REACHED();
return;
}
m_connections.append(connection);
}
void FrontendRouter::disconnectFrontend(FrontendChannel* connection)
{
ASSERT_ARG(connection, connection);
if (!m_connections.contains(connection)) {
ASSERT_NOT_REACHED();
return;
}
m_connections.removeFirst(connection);
}
void FrontendRouter::disconnectAllFrontends()
{
m_connections.clear();
}
bool FrontendRouter::hasLocalFrontend() const
{
for (auto* connection : m_connections) {
if (connection->connectionType() == FrontendChannel::ConnectionType::Local)
return true;
}
return false;
}
bool FrontendRouter::hasRemoteFrontend() const
{
for (auto* connection : m_connections) {
if (connection->connectionType() == FrontendChannel::ConnectionType::Remote)
return true;
}
return false;
}
void FrontendRouter::sendEvent(const String& message) const
{
for (auto* connection : m_connections)
connection->sendMessageToFrontend(message);
}
void FrontendRouter::sendResponse(const String& message) const
{
for (auto* connection : m_connections)
connection->sendMessageToFrontend(message);
}
}