summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Sluift/SluiftClient.cpp5
-rw-r--r--Sluift/SluiftComponent.cpp5
-rw-r--r--Swiften/Component/CoreComponent.cpp10
-rw-r--r--Swiften/Component/CoreComponent.h17
4 files changed, 30 insertions, 7 deletions
diff --git a/Sluift/SluiftClient.cpp b/Sluift/SluiftClient.cpp
index e8c43c9..5243ed0 100644
--- a/Sluift/SluiftClient.cpp
+++ b/Sluift/SluiftClient.cpp
@@ -1,3 +1,3 @@
/*
- * Copyright (c) 2013-2017 Isode Limited.
+ * Copyright (c) 2013-2018 Isode Limited.
* All rights reserved.
@@ -50,2 +50,5 @@ SluiftClient::~SluiftClient() {
void SluiftClient::connect() {
+ if (client->isActive()) {
+ throw Lua::Exception("Client is already connecting or connected");
+ }
rosterReceived = false;
diff --git a/Sluift/SluiftComponent.cpp b/Sluift/SluiftComponent.cpp
index e1d1738..126562e 100644
--- a/Sluift/SluiftComponent.cpp
+++ b/Sluift/SluiftComponent.cpp
@@ -1,3 +1,3 @@
/*
- * Copyright (c) 2014-2016 Isode Limited.
+ * Copyright (c) 2014-2018 Isode Limited.
* All rights reserved.
@@ -43,2 +43,5 @@ SluiftComponent::~SluiftComponent() {
void SluiftComponent::connect(const std::string& host, int port) {
+ if (component->isActive()) {
+ throw Lua::Exception("Component is already connecting or connected");
+ }
disconnectedError = boost::optional<ComponentError>();
diff --git a/Swiften/Component/CoreComponent.cpp b/Swiften/Component/CoreComponent.cpp
index 3896bdd..5b2277b 100644
--- a/Swiften/Component/CoreComponent.cpp
+++ b/Swiften/Component/CoreComponent.cpp
@@ -1,3 +1,3 @@
/*
- * Copyright (c) 2010-2016 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
@@ -168,2 +168,10 @@ void CoreComponent::sendData(const std::string& data) {
+bool CoreComponent::isActive() const {
+ return session_ || connector_;
+}
+
+bool CoreComponent::isAvailable() const {
+ return stanzaChannel_->isAvailable();
+}
+
}
diff --git a/Swiften/Component/CoreComponent.h b/Swiften/Component/CoreComponent.h
index f673643..1a487d2 100644
--- a/Swiften/Component/CoreComponent.h
+++ b/Swiften/Component/CoreComponent.h
@@ -1,3 +1,3 @@
/*
- * Copyright (c) 2010-2017 Isode Limited.
+ * Copyright (c) 2010-2018 Isode Limited.
* All rights reserved.
@@ -63,5 +63,14 @@ namespace Swift {
- bool isAvailable() const {
- return stanzaChannel_->isAvailable();
- }
+ /**
+ * Checks whether the component is connected to the server,
+ * and stanzas can be sent.
+ */
+ bool isAvailable() const;
+
+ /**
+ * Checks whether the component is active.
+ *
+ * A component is active when it is connected or connecting to the server.
+ */
+ bool isActive() const;