summaryrefslogtreecommitdiff
path: root/cpp/demo/IceGrid/simple/Client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/demo/IceGrid/simple/Client.cpp')
-rw-r--r--cpp/demo/IceGrid/simple/Client.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/cpp/demo/IceGrid/simple/Client.cpp b/cpp/demo/IceGrid/simple/Client.cpp
index 13259587dfb..bf86e3ee294 100644
--- a/cpp/demo/IceGrid/simple/Client.cpp
+++ b/cpp/demo/IceGrid/simple/Client.cpp
@@ -19,6 +19,7 @@ class HelloClient : public Ice::Application
public:
virtual int run(int, char*[]);
+ virtual void interruptCallback(int);
private:
@@ -47,6 +48,12 @@ int
HelloClient::run(int argc, char* argv[])
{
//
+ // Since this is an interactive demo we want the custom interrupt
+ // callback to be called when the process is interrupted.
+ //
+ userCallbackOnInterrupt();
+
+ //
// First we try to connect to the object with the `hello'
// identity. If it's not registered with the registry, we
// search for an object with the ::Demo::Hello type.
@@ -108,3 +115,20 @@ HelloClient::run(int argc, char* argv[])
return EXIT_SUCCESS;
}
+void
+HelloClient::interruptCallback(int)
+{
+ try
+ {
+ communicator()->destroy();
+ }
+ catch(const IceUtil::Exception& ex)
+ {
+ cerr << appName() << ": " << ex << endl;
+ }
+ catch(...)
+ {
+ cerr << appName() << ": unknown exception" << endl;
+ }
+ exit(EXIT_SUCCESS);
+}