1
1
// **********************************************************************
3
// Copyright (c) 2003-2006 ZeroC, Inc. All rights reserved.
3
// Copyright (c) 2003-2007 ZeroC, Inc. All rights reserved.
5
5
// This copy of Ice is licensed to you under the terms described in the
6
6
// ICE_LICENSE file included in this distribution.
8
8
// **********************************************************************
10
#include <Ice/Application.h>
13
13
using namespace std;
35
36
HelloClient::run(int argc, char* argv[])
37
Ice::PropertiesPtr properties = communicator()->getProperties();
38
const char* proxyProperty = "Hello.Proxy";
39
string proxy = properties->getProperty(proxyProperty);
42
cerr << argv[0] << ": property `" << proxyProperty << "' not set" << endl;
39
// Since this is an interactive demo we want the custom interrupt
40
// callback to be called when the process is interrupted.
42
callbackOnInterrupt();
46
44
HelloPrx twoway = HelloPrx::checkedCast(
47
communicator()->stringToProxy(proxy)->ice_twoway()->ice_timeout(-1)->ice_secure(false));
45
communicator()->propertyToProxy("Hello.Proxy")->ice_twoway()->ice_timeout(-1)->ice_secure(false));
50
cerr << argv[0] << ": invalid proxy" << endl;
48
cerr << argv[0] << ": invalid proxy" << endl;
53
51
HelloPrx oneway = HelloPrx::uncheckedCast(twoway->ice_oneway());
54
52
HelloPrx batchOneway = HelloPrx::uncheckedCast(twoway->ice_batchOneway());
58
56
bool secure = false;
80
batchOneway->sayHello();
86
cout << "secure datagrams are not supported" << endl;
97
cout << "secure datagrams are not supported" << endl;
101
batchDatagram->sayHello();
106
communicator()->flushBatchRequests();
119
twoway = HelloPrx::uncheckedCast(twoway->ice_timeout(timeout));
120
oneway = HelloPrx::uncheckedCast(oneway->ice_timeout(timeout));
121
batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_timeout(timeout));
125
cout << "timeout is now switched off" << endl;
129
cout << "timeout is now set to 2000ms" << endl;
136
twoway = HelloPrx::uncheckedCast(twoway->ice_secure(secure));
137
oneway = HelloPrx::uncheckedCast(oneway->ice_secure(secure));
138
batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_secure(secure));
139
datagram = HelloPrx::uncheckedCast(datagram->ice_secure(secure));
140
batchDatagram = HelloPrx::uncheckedCast(batchDatagram->ice_secure(secure));
144
cout << "secure mode is now on" << endl;
148
cout << "secure mode is now off" << endl;
165
cout << "unknown command `" << c << "'" << endl;
169
catch(const Ice::Exception& ex)
71
twoway->sayHello(delay);
75
oneway->sayHello(delay);
79
batchOneway->sayHello(delay);
85
cout << "secure datagrams are not supported" << endl;
89
datagram->sayHello(delay);
96
cout << "secure datagrams are not supported" << endl;
100
batchDatagram->sayHello(delay);
105
communicator()->flushBatchRequests();
118
twoway = HelloPrx::uncheckedCast(twoway->ice_timeout(timeout));
119
oneway = HelloPrx::uncheckedCast(oneway->ice_timeout(timeout));
120
batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_timeout(timeout));
124
cout << "timeout is now switched off" << endl;
128
cout << "timeout is now set to 2000ms" << endl;
144
cout << "server delay is now disabled" << endl;
148
cout << "server delay is now set to 2500ms" << endl;
155
twoway = HelloPrx::uncheckedCast(twoway->ice_secure(secure));
156
oneway = HelloPrx::uncheckedCast(oneway->ice_secure(secure));
157
batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_secure(secure));
158
datagram = HelloPrx::uncheckedCast(datagram->ice_secure(secure));
159
batchDatagram = HelloPrx::uncheckedCast(batchDatagram->ice_secure(secure));
163
cout << "secure mode is now on" << endl;
167
cout << "secure mode is now off" << endl;
184
cout << "unknown command `" << c << "'" << endl;
188
catch(const Ice::Exception& ex)
174
193
while(cin.good() && c != 'x');
199
HelloClient::interruptCallback(int)
203
communicator()->destroy();
205
catch(const IceUtil::Exception& ex)
207
cerr << appName() << ": " << ex << endl;
211
cerr << appName() << ": unknown exception" << endl;
180
217
HelloClient::menu()
184
"t: send greeting as twoway\n"
185
"o: send greeting as oneway\n"
186
"O: send greeting as batch oneway\n"
187
"d: send greeting as datagram\n"
188
"D: send greeting as batch datagram\n"
189
"f: flush all batch requests\n"
191
"S: switch secure mode on/off\n"
192
"s: shutdown server\n"
221
"t: send greeting as twoway\n"
222
"o: send greeting as oneway\n"
223
"O: send greeting as batch oneway\n"
224
"d: send greeting as datagram\n"
225
"D: send greeting as batch datagram\n"
226
"f: flush all batch requests\n"
228
"P: set server delay\n"
229
"S: switch secure mode on/off\n"
230
"s: shutdown server\n"