diff options
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/demo/Ice/hello/Client.cpp | 32 | ||||
-rw-r--r-- | cpp/demo/Ice/hello/Hello.ice | 2 | ||||
-rw-r--r-- | cpp/demo/Ice/hello/HelloI.cpp | 6 | ||||
-rw-r--r-- | cpp/demo/Ice/hello/HelloI.h | 2 | ||||
-rw-r--r-- | cpp/demo/Ice/hello/README | 4 | ||||
-rw-r--r-- | cpp/demo/Ice/hello/config.client | 2 | ||||
-rw-r--r-- | cpp/demo/Ice/hello/config.server | 2 | ||||
-rw-r--r-- | cpp/demo/IceBox/hello/Client.cpp | 26 |
8 files changed, 40 insertions, 36 deletions
diff --git a/cpp/demo/Ice/hello/Client.cpp b/cpp/demo/Ice/hello/Client.cpp index af045cef957..3aca8c3d934 100644 --- a/cpp/demo/Ice/hello/Client.cpp +++ b/cpp/demo/Ice/hello/Client.cpp @@ -48,6 +48,7 @@ HelloClient::run(int argc, char* argv[]) bool secure = false; int timeout = -1; + int delay = 0; menu(); @@ -60,15 +61,15 @@ HelloClient::run(int argc, char* argv[]) cin >> c; if(c == 't') { - twoway->sayHello(); + twoway->sayHello(delay); } else if(c == 'o') { - oneway->sayHello(); + oneway->sayHello(delay); } else if(c == 'O') { - batchOneway->sayHello(); + batchOneway->sayHello(delay); } else if(c == 'd') { @@ -78,7 +79,7 @@ HelloClient::run(int argc, char* argv[]) } else { - datagram->sayHello(); + datagram->sayHello(delay); } } else if(c == 'D') @@ -89,7 +90,7 @@ HelloClient::run(int argc, char* argv[]) } else { - batchDatagram->sayHello(); + batchDatagram->sayHello(delay); } } else if(c == 'f') @@ -120,6 +121,26 @@ HelloClient::run(int argc, char* argv[]) cout << "timeout is now set to 2000ms" << endl; } } + else if(c == 'P') + { + if(delay == 0) + { + delay = 2500; + } + else + { + delay = 0; + } + + if(delay == -1) + { + cout << "server delay is now disabled" << endl; + } + else + { + cout << "server delay is now set to 2500ms" << endl; + } + } else if(c == 'S') { secure = !secure; @@ -179,6 +200,7 @@ HelloClient::menu() "D: send greeting as batch datagram\n" "f: flush all batch requests\n" "T: set a timeout\n" + "P: set server delay\n" "S: switch secure mode on/off\n" "s: shutdown server\n" "x: exit\n" diff --git a/cpp/demo/Ice/hello/Hello.ice b/cpp/demo/Ice/hello/Hello.ice index cb3bcab35ee..c7c88563dff 100644 --- a/cpp/demo/Ice/hello/Hello.ice +++ b/cpp/demo/Ice/hello/Hello.ice @@ -15,7 +15,7 @@ module Demo interface Hello { - ["cpp:const"] idempotent void sayHello(); + ["cpp:const"] idempotent void sayHello(int delay); idempotent void shutdown(); }; diff --git a/cpp/demo/Ice/hello/HelloI.cpp b/cpp/demo/Ice/hello/HelloI.cpp index ddac03f9762..aa74095dc0a 100644 --- a/cpp/demo/Ice/hello/HelloI.cpp +++ b/cpp/demo/Ice/hello/HelloI.cpp @@ -13,8 +13,12 @@ using namespace std; void -HelloI::sayHello(const Ice::Current&) const +HelloI::sayHello(int delay, const Ice::Current&) const { + if(delay != 0) + { + IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(delay)); + } cout << "Hello World!" << endl; } diff --git a/cpp/demo/Ice/hello/HelloI.h b/cpp/demo/Ice/hello/HelloI.h index d3e0650d577..36933a553cb 100644 --- a/cpp/demo/Ice/hello/HelloI.h +++ b/cpp/demo/Ice/hello/HelloI.h @@ -16,7 +16,7 @@ class HelloI : public Demo::Hello { public: - virtual void sayHello(const Ice::Current&) const; + virtual void sayHello(int delay, const Ice::Current&) const; virtual void shutdown(const Ice::Current&); }; diff --git a/cpp/demo/Ice/hello/README b/cpp/demo/Ice/hello/README index 63c9dba1e7d..cf79f825151 100644 --- a/cpp/demo/Ice/hello/README +++ b/cpp/demo/Ice/hello/README @@ -9,3 +9,7 @@ $ server In a separate window, start the client: $ client + +To test timeouts you can use 'T' to set a timeout on +the client proxy and 'P' to set a delayed response in +the server to cause a timeout. diff --git a/cpp/demo/Ice/hello/config.client b/cpp/demo/Ice/hello/config.client index 11b0577c8cf..4c70261fe76 100644 --- a/cpp/demo/Ice/hello/config.client +++ b/cpp/demo/Ice/hello/config.client @@ -7,7 +7,7 @@ Hello.Proxy=hello:tcp -p 10000:udp -p 10000:ssl -p 10001 # # Warn about connection exceptions # -Ice.Warn.Connections=1 +#Ice.Warn.Connections=1 # # We want a faster ACM for this demo. diff --git a/cpp/demo/Ice/hello/config.server b/cpp/demo/Ice/hello/config.server index 6c38bfb6fbf..bb2040f2cdc 100644 --- a/cpp/demo/Ice/hello/config.server +++ b/cpp/demo/Ice/hello/config.server @@ -8,7 +8,7 @@ Hello.Endpoints=tcp -p 10000:udp -p 10000:ssl -p 10001 # # Warn about connection exceptions # -Ice.Warn.Connections=1 +#Ice.Warn.Connections=1 # # We want a faster ACM for this demo. diff --git a/cpp/demo/IceBox/hello/Client.cpp b/cpp/demo/IceBox/hello/Client.cpp index b4578d987e7..17764a6a845 100644 --- a/cpp/demo/IceBox/hello/Client.cpp +++ b/cpp/demo/IceBox/hello/Client.cpp @@ -42,7 +42,6 @@ HelloClient::menu() "d: send greeting as datagram\n" "D: send greeting as batch datagram\n" "f: flush all batch requests\n" - "T: set a timeout\n" "S: switch secure mode on/off\n" "x: exit\n" "?: help\n"; @@ -64,7 +63,6 @@ HelloClient::run(int argc, char* argv[]) HelloPrx batchDatagram = HelloPrx::uncheckedCast(twoway->ice_batchDatagram()); bool secure = false; - int timeout = -1; menu(); @@ -113,30 +111,6 @@ HelloClient::run(int argc, char* argv[]) { communicator()->flushBatchRequests(); } - else if(c == 'T') - { - if(timeout == -1) - { - timeout = 2000; - } - else - { - timeout = -1; - } - - twoway = HelloPrx::uncheckedCast(twoway->ice_timeout(timeout)); - oneway = HelloPrx::uncheckedCast(oneway->ice_timeout(timeout)); - batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_timeout(timeout)); - - if(timeout == -1) - { - cout << "timeout is now switched off" << endl; - } - else - { - cout << "timeout is now set to 2000ms" << endl; - } - } else if(c == 'S') { secure = !secure; |