summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/Examples')
-rw-r--r--Swiften/Examples/SendMessage/SendMessage.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/Swiften/Examples/SendMessage/SendMessage.cpp b/Swiften/Examples/SendMessage/SendMessage.cpp
index b7a80dd..7699eef 100644
--- a/Swiften/Examples/SendMessage/SendMessage.cpp
+++ b/Swiften/Examples/SendMessage/SendMessage.cpp
@@ -16,6 +16,8 @@ SimpleEventLoop eventLoop;
Client* client = 0;
JID recipient;
std::string messageBody;
+int exitCode = 0;
+
void handleConnected() {
boost::shared_ptr<Message> message(new Message());
@@ -26,6 +28,11 @@ void handleConnected() {
eventLoop.stop();
}
+void handleError(const ClientError&) {
+ std::cerr << "Error!" << std::endl;
+ exitCode = 1;
+}
+
int main(int argc, char* argv[]) {
if (argc != 5) {
std::cerr << "Usage: " << argv[0] << " <jid> <password> <recipient> <message>" << std::endl;
@@ -38,6 +45,7 @@ int main(int argc, char* argv[]) {
client = new Swift::Client(JID(argv[1]), String(argv[2]));
ClientXMLTracer* tracer = new ClientXMLTracer(client);
client->onConnected.connect(&handleConnected);
+ client->onError.connect(&handleError);
client->connect();
{
@@ -50,4 +58,5 @@ int main(int argc, char* argv[]) {
delete tracer;
delete client;
+ return exitCode;
}