summaryrefslogtreecommitdiff
path: root/cpp/demo/Ice/hello/Client.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/demo/Ice/hello/Client.cpp')
-rw-r--r--cpp/demo/Ice/hello/Client.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/cpp/demo/Ice/hello/Client.cpp b/cpp/demo/Ice/hello/Client.cpp
index 3aca8c3d934..f2de173ada6 100644
--- a/cpp/demo/Ice/hello/Client.cpp
+++ b/cpp/demo/Ice/hello/Client.cpp
@@ -18,6 +18,7 @@ class HelloClient : public Ice::Application
public:
virtual int run(int, char*[]);
+ virtual void interruptCallback(int);
private:
@@ -34,6 +35,12 @@ main(int argc, char* argv[])
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();
+
HelloPrx twoway = HelloPrx::checkedCast(
communicator()->propertyToProxy("Hello.Proxy")->ice_twoway()->ice_timeout(-1)->ice_secure(false));
if(!twoway)
@@ -189,6 +196,24 @@ HelloClient::run(int argc, char* argv[])
}
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);
+}
+
+void
HelloClient::menu()
{
cout <<