summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-03-30 08:46:08 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-03-30 08:46:24 (GMT)
commit9593ec65fa0def4c840d8a68578c671bbf0981c9 (patch)
tree201865a79109ab49e060df6df6ad6ee8679ae5bd /Swiften/Examples
parentc87a58a698ecaca2e6c4577e1e645b38a2c32e67 (diff)
downloadswift-9593ec65fa0def4c840d8a68578c671bbf0981c9.zip
swift-9593ec65fa0def4c840d8a68578c671bbf0981c9.tar.bz2
Basic error handling for SendMessage example.
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;
}