diff options
Diffstat (limited to 'cpp/demo/Ice/value/Client.cpp')
-rw-r--r-- | cpp/demo/Ice/value/Client.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/cpp/demo/Ice/value/Client.cpp b/cpp/demo/Ice/value/Client.cpp index a375da519de..de4885f7f79 100644 --- a/cpp/demo/Ice/value/Client.cpp +++ b/cpp/demo/Ice/value/Client.cpp @@ -19,6 +19,7 @@ class ValueClient : public Ice::Application public: virtual int run(int, char*[]); + virtual void interruptCallback(int); }; int @@ -31,6 +32,12 @@ main(int argc, char* argv[]) int ValueClient::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(); + Ice::ObjectPrx base = communicator()->propertyToProxy("Value.Initial"); InitialPrx initial = InitialPrx::checkedCast(base); if(!initial) @@ -174,3 +181,21 @@ ValueClient::run(int argc, char* argv[]) return EXIT_SUCCESS; } + +void +ValueClient::interruptCallback(int) +{ + try + { + communicator()->destroy(); + } + catch(const IceUtil::Exception& ex) + { + cerr << appName() << ": " << ex << endl; + } + catch(...) + { + cerr << appName() << ": unknown exception" << endl; + } + exit(EXIT_SUCCESS); +} |