From 9593ec65fa0def4c840d8a68578c671bbf0981c9 Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Tue, 30 Mar 2010 09:46:08 +0100
Subject: Basic error handling for SendMessage example.


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;
 }
-- 
cgit v0.10.2-6-g49f6