diff options
Diffstat (limited to 'Sluift/SluiftComponent.cpp')
| -rw-r--r-- | Sluift/SluiftComponent.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/Sluift/SluiftComponent.cpp b/Sluift/SluiftComponent.cpp index e1d1738..74728ee 100644 --- a/Sluift/SluiftComponent.cpp +++ b/Sluift/SluiftComponent.cpp @@ -1,7 +1,7 @@ /* - * Copyright (c) 2014-2016 Isode Limited. + * Copyright (c) 2014-2018 Isode Limited. * All rights reserved. * See the COPYING file for more information. */ #include <Sluift/SluiftComponent.h> @@ -38,11 +38,14 @@ SluiftComponent::SluiftComponent( SluiftComponent::~SluiftComponent() { delete tracer; delete component; } -void SluiftComponent::connect(const std::string& host, int port) { +void SluiftComponent::connect(const std::string& host, unsigned short port) { + if (component->isActive()) { + throw Lua::Exception("Component is already connecting or connected"); + } disconnectedError = boost::optional<ComponentError>(); component->connect(host, port); } void SluiftComponent::setTraceEnabled(bool b) { @@ -73,11 +76,11 @@ bool SluiftComponent::isConnected() const { return component->isAvailable(); } void SluiftComponent::disconnect() { component->disconnect(); - while (component->isAvailable()) { + while (component->isActive()) { eventLoop->runUntilEvents(); } } void SluiftComponent::setSoftwareVersion(const std::string& name, const std::string& version, const std::string& /* os */) { @@ -100,16 +103,16 @@ boost::optional<SluiftComponent::Event> SluiftComponent::getNextEvent( } ++currentIndex; } // Wait for new events - while (!watchdog.getTimedOut() && currentIndex >= pendingEvents.size() && component->isAvailable()) { + while (!watchdog.getTimedOut() && currentIndex >= pendingEvents.size() && component->isActive()) { eventLoop->runUntilEvents(); } // Finish if we're disconnected or timed out - if (watchdog.getTimedOut() || !component->isAvailable()) { + if (watchdog.getTimedOut() || !component->isActive()) { return boost::optional<Event>(); } } } |
Swift