summaryrefslogtreecommitdiff
path: root/cppe/demo
diff options
context:
space:
mode:
Diffstat (limited to 'cppe/demo')
-rw-r--r--cppe/demo/IceE/MFC/client/HelloClient.cpp40
-rw-r--r--cppe/demo/IceE/MFC/client/HelloClientDlg.cpp4
-rw-r--r--cppe/demo/IceE/MFC/client/stdafx.h8
-rw-r--r--cppe/demo/IceE/MFC/server/HelloServer.cpp40
-rw-r--r--cppe/demo/IceE/MFC/server/LogI.cpp4
-rw-r--r--cppe/demo/IceE/MFC/server/stdafx.h8
-rw-r--r--cppe/demo/IceE/bidir/CallbackI.cpp74
-rw-r--r--cppe/demo/IceE/bidir/CallbackI.h19
-rw-r--r--cppe/demo/IceE/bidir/Client.cpp17
-rw-r--r--cppe/demo/IceE/bidir/Server.cpp8
-rw-r--r--cppe/demo/IceE/bidir/config7
-rw-r--r--cppe/demo/IceE/bidir/config.client28
-rw-r--r--cppe/demo/IceE/bidir/config.server29
-rw-r--r--cppe/demo/IceE/callback/CallbackSenderI.cpp8
-rw-r--r--cppe/demo/IceE/callback/Client.cpp111
-rw-r--r--cppe/demo/IceE/callback/Server.cpp5
-rw-r--r--cppe/demo/IceE/callback/config7
-rw-r--r--cppe/demo/IceE/callback/config.client35
-rw-r--r--cppe/demo/IceE/callback/config.server29
-rw-r--r--cppe/demo/IceE/chat/ChatClient.cpp4
-rw-r--r--cppe/demo/IceE/chat/ChatClientDlg.cpp300
-rw-r--r--cppe/demo/IceE/chat/ChatConfigDlg.cpp2
-rw-r--r--cppe/demo/IceE/chat/Client.cpp124
-rw-r--r--cppe/demo/IceE/chat/LogI.cpp4
-rw-r--r--cppe/demo/IceE/chat/README4
-rw-r--r--cppe/demo/IceE/chat/Router.ice4
-rw-r--r--cppe/demo/IceE/chat/Session.ice2
-rw-r--r--cppe/demo/IceE/chat/config28
-rw-r--r--cppe/demo/IceE/chat/stdafx.h8
-rw-r--r--cppe/demo/IceE/hello/Client.cpp220
-rw-r--r--cppe/demo/IceE/hello/Server.cpp34
-rw-r--r--cppe/demo/IceE/hello/config.client (renamed from cppe/demo/IceE/hello/config)13
-rw-r--r--cppe/demo/IceE/hello/config.server (renamed from cppe/demo/IceE/minimal/config)10
-rw-r--r--cppe/demo/IceE/latency/Client.cpp42
-rw-r--r--cppe/demo/IceE/latency/Server.cpp39
-rw-r--r--cppe/demo/IceE/latency/WinCEClient.cpp256
-rw-r--r--cppe/demo/IceE/latency/WinCEServer.cpp187
-rw-r--r--cppe/demo/IceE/latency/config7
-rw-r--r--cppe/demo/IceE/latency/config.client5
-rw-r--r--cppe/demo/IceE/latency/config.server10
-rw-r--r--cppe/demo/IceE/minimal/Client.cpp117
-rw-r--r--cppe/demo/IceE/minimal/Server.cpp60
-rw-r--r--cppe/demo/IceE/minimal/WinCEClient.cpp88
-rw-r--r--cppe/demo/IceE/minimal/WinCEServer.cpp205
-rw-r--r--cppe/demo/IceE/throughput/Client.cpp685
-rw-r--r--cppe/demo/IceE/throughput/Server.cpp42
-rw-r--r--cppe/demo/IceE/throughput/Throughput.ice4
-rw-r--r--cppe/demo/IceE/throughput/ThroughputI.cpp68
-rw-r--r--cppe/demo/IceE/throughput/ThroughputI.h5
-rw-r--r--cppe/demo/IceE/throughput/WinCEClient.cpp410
-rw-r--r--cppe/demo/IceE/throughput/WinCEServer.cpp184
-rw-r--r--cppe/demo/IceE/throughput/config7
-rw-r--r--cppe/demo/IceE/throughput/config.client5
-rw-r--r--cppe/demo/IceE/throughput/config.server11
-rw-r--r--cppe/demo/IceE/workqueue/WorkQueue.cpp90
55 files changed, 1957 insertions, 1808 deletions
diff --git a/cppe/demo/IceE/MFC/client/HelloClient.cpp b/cppe/demo/IceE/MFC/client/HelloClient.cpp
index 03f55a05a5d..fbb96b11150 100644
--- a/cppe/demo/IceE/MFC/client/HelloClient.cpp
+++ b/cppe/demo/IceE/MFC/client/HelloClient.cpp
@@ -46,30 +46,30 @@ CHelloClientApp::InitInstance()
try
{
int argc = 0;
- Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
- //
- // Set a default value for Hello.Proxy so that the demo will
- // run without a configuration file.
- //
- initData.properties->setProperty("Hello.Proxy", "hello:tcp -p 10000");
+ Ice::InitializationData initData;
+ initData.properties = Ice::createProperties();
+ //
+ // Set a default value for Hello.Proxy so that the demo will
+ // run without a configuration file.
+ //
+ initData.properties->setProperty("Hello.Proxy", "hello:tcp -p 10000");
- //
- // Now, load the configuration file if present. Under WinCE we
- // use "config.txt" since it can be edited with pocket word.
- //
+ //
+ // Now, load the configuration file if present. Under WinCE we
+ // use "config.txt" since it can be edited with pocket word.
+ //
#ifdef _WIN32_WCE
- string config = "config.txt";
+ string config = "config.txt";
#else
- string config = "config";
+ string config = "config";
#endif
- try
- {
- initData.properties->load(config);
- }
- catch(const Ice::FileException&)
- {
- }
+ try
+ {
+ initData.properties->load(config);
+ }
+ catch(const Ice::FileException&)
+ {
+ }
communicator = Ice::initialize(argc, 0, initData);
}
diff --git a/cppe/demo/IceE/MFC/client/HelloClientDlg.cpp b/cppe/demo/IceE/MFC/client/HelloClientDlg.cpp
index 5ccb10cd449..f0fb65c754a 100644
--- a/cppe/demo/IceE/MFC/client/HelloClientDlg.cpp
+++ b/cppe/demo/IceE/MFC/client/HelloClientDlg.cpp
@@ -59,7 +59,6 @@ CHelloClientDlg::OnInitDialog()
//
_mode->SetCurSel(_currentMode);
-
//
// Disable flush button if built without batch support.
//
@@ -67,7 +66,6 @@ CHelloClientDlg::OnInitDialog()
(CButton*)GetDlgItem(IDC_FLUSH)->EnableWindow(FALSE);
#endif
-
//
// Create the proxy.
//
@@ -214,7 +212,7 @@ CHelloClientDlg::updateProxy()
#else
AfxMessageBox(CString("Batch mode is currently not enabled."),
MB_OK|MB_ICONEXCLAMATION);
- return;
+ return;
#endif
default:
assert(false);
diff --git a/cppe/demo/IceE/MFC/client/stdafx.h b/cppe/demo/IceE/MFC/client/stdafx.h
index f3bc1290dc9..a4761e36b74 100644
--- a/cppe/demo/IceE/MFC/client/stdafx.h
+++ b/cppe/demo/IceE/MFC/client/stdafx.h
@@ -49,22 +49,22 @@
#endif // _WIN32_WCE
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#if defined(_WIN32_WCE) && (_WIN32_WCE >= 211) && (_AFXDLL)
-#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
+#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h> // MFC support for Windows Common Controls
+#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
-#include <afxsock.h> // MFC socket extensions
+#include <afxsock.h> // MFC socket extensions
//{{AFX_INSERT_LOCATION}}
// Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line.
diff --git a/cppe/demo/IceE/MFC/server/HelloServer.cpp b/cppe/demo/IceE/MFC/server/HelloServer.cpp
index 98194c1e96a..bd5f3391a3c 100644
--- a/cppe/demo/IceE/MFC/server/HelloServer.cpp
+++ b/cppe/demo/IceE/MFC/server/HelloServer.cpp
@@ -50,34 +50,34 @@ BOOL CHelloServerApp::InitInstance()
try
{
int argc = 0;
- Ice::InitializationData initData;
+ Ice::InitializationData initData;
initData.properties = Ice::createProperties();
- //
- // Set a default value for Hello.Endpoints so that the demo
- // will run without a configuration file.
- //
- initData.properties->setProperty("Hello.Endpoints", "tcp -p 10000");
+ //
+ // Set a default value for Hello.Endpoints so that the demo
+ // will run without a configuration file.
+ //
+ initData.properties->setProperty("Hello.Endpoints", "tcp -p 10000");
- //
- // Now, load the configuration file if present. Under WinCE we
- // use "config.txt" since it can be edited with pocket word.
- //
+ //
+ // Now, load the configuration file if present. Under WinCE we
+ // use "config.txt" since it can be edited with pocket word.
+ //
#ifdef _WIN32_WCE
- string config = "config.txt";
+ string config = "config.txt";
#else
- string config = "config";
+ string config = "config";
#endif
- try
- {
- initData.properties->load(config);
- }
- catch(const Ice::FileException&)
- {
- }
+ try
+ {
+ initData.properties->load(config);
+ }
+ catch(const Ice::FileException&)
+ {
+ }
log = new LogI;
- initData.logger = log;
+ initData.logger = log;
communicator = Ice::initialize(argc, 0, initData);
adapter = communicator->createObjectAdapter("Hello");
diff --git a/cppe/demo/IceE/MFC/server/LogI.cpp b/cppe/demo/IceE/MFC/server/LogI.cpp
index dbed3ad13c9..7577334bb12 100644
--- a/cppe/demo/IceE/MFC/server/LogI.cpp
+++ b/cppe/demo/IceE/MFC/server/LogI.cpp
@@ -65,7 +65,7 @@ LogI::message(const string& msg)
string line = msg + "\r\n";
if(_hwnd)
{
- post(line);
+ post(line);
}
else
{
@@ -79,7 +79,7 @@ LogI::setHandle(HWND hwnd)
_hwnd = hwnd;
if(_hwnd != 0 && !_buffer.empty())
{
- post(_buffer);
+ post(_buffer);
_buffer.clear();
}
}
diff --git a/cppe/demo/IceE/MFC/server/stdafx.h b/cppe/demo/IceE/MFC/server/stdafx.h
index ab60a56baa8..0affd98b539 100644
--- a/cppe/demo/IceE/MFC/server/stdafx.h
+++ b/cppe/demo/IceE/MFC/server/stdafx.h
@@ -50,22 +50,22 @@
#endif // _WIN32_WCE
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#if defined(_WIN32_WCE) && (_WIN32_WCE >= 211) && (_AFXDLL)
-#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
+#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h> // MFC support for Windows Common Controls
+#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
-#include <afxsock.h> // MFC socket extensions
+#include <afxsock.h> // MFC socket extensions
//{{AFX_INSERT_LOCATION}}
// Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line.
diff --git a/cppe/demo/IceE/bidir/CallbackI.cpp b/cppe/demo/IceE/bidir/CallbackI.cpp
index defd118bec3..ec486167729 100644
--- a/cppe/demo/IceE/bidir/CallbackI.cpp
+++ b/cppe/demo/IceE/bidir/CallbackI.cpp
@@ -15,7 +15,6 @@ using namespace Demo;
CallbackSenderI::CallbackSenderI(const Ice::CommunicatorPtr& communicator) :
_communicator(communicator),
_destroy(false),
- _num(0),
_callbackSenderThread(new CallbackSenderThread(this))
{
}
@@ -26,15 +25,15 @@ CallbackSenderI::destroy()
IceUtil::ThreadPtr callbackSenderThread;
{
- Lock lock(*this);
-
- printf("destroying callback sender\n");
- _destroy = true;
-
- notify();
+ Lock lock(*this);
+
+ printf("destroying callback sender\n");
+ _destroy = true;
+
+ notify();
- callbackSenderThread = _callbackSenderThread;
- _callbackSenderThread = 0; // Resolve cyclic dependency.
+ callbackSenderThread = _callbackSenderThread;
+ _callbackSenderThread = 0; // Resolve cyclic dependency.
}
callbackSenderThread->getThreadControl().join();
@@ -60,32 +59,39 @@ CallbackSenderI::start()
void
CallbackSenderI::run()
{
- Lock lock(*this);
-
- while(!_destroy)
+ int num = 0;
+ while(true)
{
- timedWait(IceUtil::Time::seconds(2));
+ std::set<Demo::CallbackReceiverPrx> clients;
+ {
+ Lock lock(*this);
+ timedWait(IceUtil::Time::seconds(2));
+
+ if(_destroy)
+ {
+ break;
+ }
+
+ clients = _clients;
+ }
- if(!_destroy && !_clients.empty())
- {
- ++_num;
-
- set<CallbackReceiverPrx>::iterator p = _clients.begin();
- while(p != _clients.end())
- {
- try
- {
- (*p)->callback(_num);
- ++p;
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "removing client `%s':\n%s\n",
- _communicator->identityToString((*p)->ice_getIdentity()).c_str(),
- ex.toString().c_str());
- _clients.erase(p++);
- }
- }
- }
+ if(!clients.empty())
+ {
+ ++num;
+ for(set<CallbackReceiverPrx>::iterator p = clients.begin(); p != clients.end(); ++p)
+ {
+ try
+ {
+ (*p)->callback(num);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ fprintf(stderr, "removing client `%s':\n%s\n",
+ _communicator->identityToString((*p)->ice_getIdentity()).c_str(),
+ ex.toString().c_str());
+ _clients.erase(*p);
+ }
+ }
+ }
}
}
diff --git a/cppe/demo/IceE/bidir/CallbackI.h b/cppe/demo/IceE/bidir/CallbackI.h
index 922410f76c1..6fd80632369 100644
--- a/cppe/demo/IceE/bidir/CallbackI.h
+++ b/cppe/demo/IceE/bidir/CallbackI.h
@@ -34,7 +34,6 @@ private:
Ice::CommunicatorPtr _communicator;
bool _destroy;
- Ice::Int _num;
std::set<Demo::CallbackReceiverPrx> _clients;
//
@@ -47,19 +46,19 @@ private:
{
public:
- CallbackSenderThread(const CallbackSenderIPtr& callbackSender) :
- _callbackSender(callbackSender)
- {
- }
+ CallbackSenderThread(const CallbackSenderIPtr& callbackSender) :
+ _callbackSender(callbackSender)
+ {
+ }
- virtual void run()
- {
- _callbackSender->run();
- }
+ virtual void run()
+ {
+ _callbackSender->run();
+ }
private:
- CallbackSenderIPtr _callbackSender;
+ CallbackSenderIPtr _callbackSender;
};
IceUtil::ThreadPtr _callbackSenderThread;
diff --git a/cppe/demo/IceE/bidir/Client.cpp b/cppe/demo/IceE/bidir/Client.cpp
index dc982affc9f..4d5084bca5f 100644
--- a/cppe/demo/IceE/bidir/Client.cpp
+++ b/cppe/demo/IceE/bidir/Client.cpp
@@ -20,7 +20,7 @@ public:
virtual void
callback(Ice::Int num, const Ice::Current&)
{
- printf("received callback #%d\n", num);
+ printf("received callback #%d\n", num);
}
};
@@ -34,26 +34,27 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
}
Ice::PropertiesPtr properties = communicator->getProperties();
- const char* proxyProperty = "Callback.Client.CallbackServer";
+ const char* proxyProperty = "CallbackSender.Proxy";
string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
{
- fprintf(stderr, "%s: property `%s' not set\n", argv[0], proxyProperty);
- return EXIT_FAILURE;
+ fprintf(stderr, "%s: property `%s' not set\n", argv[0], proxyProperty);
+ return EXIT_FAILURE;
}
CallbackSenderPrx server = CallbackSenderPrx::checkedCast(communicator->stringToProxy(proxy));
if(!server)
{
- fprintf(stderr, "%s: invalid proxy\n", argv[0]);
- return EXIT_FAILURE;
+ fprintf(stderr, "%s: invalid proxy\n", argv[0]);
+ return EXIT_FAILURE;
}
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Callback.Client");
Ice::Identity ident;
ident.name = IceUtil::generateUUID();
ident.category = "";
- adapter->add(new CallbackReceiverI, ident);
+ CallbackReceiverPtr cr = new CallbackReceiverI;
+ adapter->add(cr, ident);
adapter->activate();
server->ice_getConnection()->setAdapter(adapter);
server->addClient(ident);
@@ -72,7 +73,7 @@ main(int argc, char* argv[])
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties();
- initData.properties->load("config");
+ initData.properties->load("config.client");
communicator = Ice::initialize(argc, argv, initData);
status = run(argc, argv, communicator);
}
diff --git a/cppe/demo/IceE/bidir/Server.cpp b/cppe/demo/IceE/bidir/Server.cpp
index 949fb23d2df..08b07d343de 100644
--- a/cppe/demo/IceE/bidir/Server.cpp
+++ b/cppe/demo/IceE/bidir/Server.cpp
@@ -29,12 +29,12 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
sender->start();
try
{
- communicator->waitForShutdown();
+ communicator->waitForShutdown();
}
catch(...)
{
- sender->destroy();
- throw;
+ sender->destroy();
+ throw;
}
sender->destroy();
@@ -51,7 +51,7 @@ main(int argc, char* argv[])
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties();
- initData.properties->load("config");
+ initData.properties->load("config.server");
communicator = Ice::initialize(argc, argv, initData);
status = run(argc, argv, communicator);
}
diff --git a/cppe/demo/IceE/bidir/config b/cppe/demo/IceE/bidir/config
deleted file mode 100644
index d194f5d3765..00000000000
--- a/cppe/demo/IceE/bidir/config
+++ /dev/null
@@ -1,7 +0,0 @@
-Callback.Client.CallbackServer=sender:tcp -p 10000
-Callback.Client.Endpoints=
-Callback.Server.Endpoints=tcp -p 10000
-
-#Ice.Trace.Network=1
-#Ice.Trace.Protocol=1
-Ice.Warn.Connections=1
diff --git a/cppe/demo/IceE/bidir/config.client b/cppe/demo/IceE/bidir/config.client
new file mode 100644
index 00000000000..fa7a6ae7fb4
--- /dev/null
+++ b/cppe/demo/IceE/bidir/config.client
@@ -0,0 +1,28 @@
+#
+# The client reads this property to create the reference to the
+# "CallbackSender" object in the server.
+#
+CallbackSender.Proxy=sender:tcp -p 10000
+
+#
+# Warn about connection exceptions
+#
+Ice.Warn.Connections=1
+
+#
+# Network Tracing
+#
+# 0 = no network tracing
+# 1 = trace connection establishment and closure
+# 2 = like 1, but more detailed
+# 3 = like 2, but also trace data transfer
+#
+#Ice.Trace.Network=1
+
+#
+# Protocol Tracing
+#
+# 0 = no protocol tracing
+# 1 = trace protocol messages
+#
+#Ice.Trace.Protocol=1
diff --git a/cppe/demo/IceE/bidir/config.server b/cppe/demo/IceE/bidir/config.server
new file mode 100644
index 00000000000..e7e23e47480
--- /dev/null
+++ b/cppe/demo/IceE/bidir/config.server
@@ -0,0 +1,29 @@
+#
+# The server creates one single object adapter with the name
+# "Callback.Server". The following line sets the endpoints for this
+# adapter.
+#
+Callback.Server.Endpoints=tcp -p 10000
+
+#
+# Warn about connection exceptions
+#
+Ice.Warn.Connections=1
+
+#
+# Network Tracing
+#
+# 0 = no network tracing
+# 1 = trace connection establishment and closure
+# 2 = like 1, but more detailed
+# 3 = like 2, but also trace data transfer
+#
+#Ice.Trace.Network=1
+
+#
+# Protocol Tracing
+#
+# 0 = no protocol tracing
+# 1 = trace protocol messages
+#
+#Ice.Trace.Protocol=1
diff --git a/cppe/demo/IceE/callback/CallbackSenderI.cpp b/cppe/demo/IceE/callback/CallbackSenderI.cpp
index cf492a4bb11..e3008b7f8d5 100644
--- a/cppe/demo/IceE/callback/CallbackSenderI.cpp
+++ b/cppe/demo/IceE/callback/CallbackSenderI.cpp
@@ -19,11 +19,11 @@ CallbackSenderI::initiateCallback(const CallbackReceiverPrx& proxy, const Ice::C
printf("initiating callback\n");
try
{
- proxy->callback(current.ctx);
+ proxy->callback(current.ctx);
}
catch(const Ice::Exception& ex)
{
- fprintf(stderr, "%s\n", ex.toString().c_str());
+ fprintf(stderr, "%s\n", ex.toString().c_str());
}
}
@@ -33,10 +33,10 @@ CallbackSenderI::shutdown(const Ice::Current& c)
printf("shutting down...\n");
try
{
- c.adapter->getCommunicator()->shutdown();
+ c.adapter->getCommunicator()->shutdown();
}
catch(const Ice::Exception& ex)
{
- fprintf(stderr, "%s\n", ex.toString().c_str());
+ fprintf(stderr, "%s\n", ex.toString().c_str());
}
}
diff --git a/cppe/demo/IceE/callback/Client.cpp b/cppe/demo/IceE/callback/Client.cpp
index da018dfec4a..dc3c2f9ab68 100644
--- a/cppe/demo/IceE/callback/Client.cpp
+++ b/cppe/demo/IceE/callback/Client.cpp
@@ -19,7 +19,7 @@ public:
virtual void callback(const Ice::Current&)
{
- printf("received callback\n");
+ printf("received callback\n");
}
};
@@ -47,30 +47,31 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
}
Ice::PropertiesPtr properties = communicator->getProperties();
- const char* proxyProperty = "Callback.Client.CallbackServer";
+ const char* proxyProperty = "CallbackSender.Proxy";
string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
{
- fprintf(stderr, "%s: property `%s' not set\n", argv[0], proxyProperty);
- return EXIT_FAILURE;
+ fprintf(stderr, "%s: property `%s' not set\n", argv[0], proxyProperty);
+ return EXIT_FAILURE;
}
Ice::ObjectPrx base = communicator->stringToProxy(proxy);
CallbackSenderPrx twoway = CallbackSenderPrx::checkedCast(base->ice_twoway()->ice_timeout(-1));
if(!twoway)
{
- fprintf(stderr, "%s: invalid proxy\n", argv[0]);
- return EXIT_FAILURE;
+ fprintf(stderr, "%s: invalid proxy\n", argv[0]);
+ return EXIT_FAILURE;
}
CallbackSenderPrx oneway = CallbackSenderPrx::uncheckedCast(twoway->ice_oneway());
CallbackSenderPrx batchOneway = CallbackSenderPrx::uncheckedCast(twoway->ice_batchOneway());
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Callback.Client");
- adapter->add(new CallbackReceiverI, communicator->stringToIdentity("callbackReceiver"));
+ CallbackReceiverPtr cr = new CallbackReceiverI;
+ adapter->add(cr, communicator->stringToIdentity("callbackReceiver"));
adapter->activate();
CallbackReceiverPrx twowayR = CallbackReceiverPrx::uncheckedCast(
- adapter->createProxy(communicator->stringToIdentity("callbackReceiver")));
+ adapter->createProxy(communicator->stringToIdentity("callbackReceiver")));
CallbackReceiverPrx onewayR = CallbackReceiverPrx::uncheckedCast(twowayR->ice_oneway());
menu();
@@ -78,52 +79,52 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
char c = EOF;
do
{
- try
- {
- printf("==> ");
- do
- {
- c = getchar();
- }
- while(c != EOF && c == '\n');
- if(c == 't')
- {
- twoway->initiateCallback(twowayR);
- }
- else if(c == 'o')
- {
- oneway->initiateCallback(onewayR);
- }
- else if(c == 'O')
- {
- batchOneway->initiateCallback(onewayR);
- }
- else if(c == 'f')
- {
- communicator->flushBatchRequests();
- }
- else if(c == 's')
- {
- twoway->shutdown();
- }
- else if(c == 'x')
- {
- // Nothing to do
- }
- else if(c == '?')
- {
- menu();
- }
- else
- {
- printf("unknown command `%c'\n", c);
- menu();
- }
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- }
+ try
+ {
+ printf("==> ");
+ do
+ {
+ c = getchar();
+ }
+ while(c != EOF && c == '\n');
+ if(c == 't')
+ {
+ twoway->initiateCallback(twowayR);
+ }
+ else if(c == 'o')
+ {
+ oneway->initiateCallback(onewayR);
+ }
+ else if(c == 'O')
+ {
+ batchOneway->initiateCallback(onewayR);
+ }
+ else if(c == 'f')
+ {
+ communicator->flushBatchRequests();
+ }
+ else if(c == 's')
+ {
+ twoway->shutdown();
+ }
+ else if(c == 'x')
+ {
+ // Nothing to do
+ }
+ else if(c == '?')
+ {
+ menu();
+ }
+ else
+ {
+ printf("unknown command `%c'\n", c);
+ menu();
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ }
}
while(c != EOF && c != 'x');
@@ -140,7 +141,7 @@ main(int argc, char* argv[])
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties();
- initData.properties->load("config");
+ initData.properties->load("config.client");
communicator = Ice::initialize(argc, argv, initData);
status = run(argc, argv, communicator);
}
diff --git a/cppe/demo/IceE/callback/Server.cpp b/cppe/demo/IceE/callback/Server.cpp
index 2950777c207..01997a21f21 100644
--- a/cppe/demo/IceE/callback/Server.cpp
+++ b/cppe/demo/IceE/callback/Server.cpp
@@ -23,7 +23,8 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
}
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Callback.Server");
- adapter->add(new CallbackSenderI, communicator->stringToIdentity("callback"));
+ CallbackSenderPtr cbs = new CallbackSenderI;
+ adapter->add(cbs, communicator->stringToIdentity("callback"));
adapter->activate();
communicator->waitForShutdown();
return EXIT_SUCCESS;
@@ -39,7 +40,7 @@ main(int argc, char* argv[])
{
Ice::InitializationData initData;
initData.properties = Ice::createProperties();
- initData.properties->load("config");
+ initData.properties->load("config.server");
communicator = Ice::initialize(argc, argv, initData);
status = run(argc, argv, communicator);
}
diff --git a/cppe/demo/IceE/callback/config b/cppe/demo/IceE/callback/config
deleted file mode 100644
index 3b224be4236..00000000000
--- a/cppe/demo/IceE/callback/config
+++ /dev/null
@@ -1,7 +0,0 @@
-Callback.Client.CallbackServer=callback:tcp -p 10000
-Callback.Client.Endpoints=tcp
-Callback.Server.Endpoints=tcp -p 10000
-
-#Ice.Trace.Network=1
-#Ice.Trace.Protocol=1
-Ice.Warn.Connections=1
diff --git a/cppe/demo/IceE/callback/config.client b/cppe/demo/IceE/callback/config.client
new file mode 100644
index 00000000000..012ddfb43b7
--- /dev/null
+++ b/cppe/demo/IceE/callback/config.client
@@ -0,0 +1,35 @@
+#
+# The client reads this property to create the reference to the
+# "CallbackSender" object in the server.
+#
+CallbackSender.Proxy=callback:tcp -p 10000
+
+#
+# The client creates one single object adapter with the name
+# "Callback.Client". The following line sets the endpoints for this
+# adapter.
+#
+Callback.Client.Endpoints=tcp
+
+#
+# Warn about connection exceptions.
+#
+Ice.Warn.Connections=1
+
+#
+# Network Tracing
+#
+# 0 = no network tracing
+# 1 = trace connection establishment and closure
+# 2 = like 1, but more detailed
+# 3 = like 2, but also trace data transfer
+#
+#Ice.Trace.Network=1
+
+#
+# Protocol Tracing
+#
+# 0 = no protocol tracing
+# 1 = trace protocol messages
+#
+#Ice.Trace.Protocol=1
diff --git a/cppe/demo/IceE/callback/config.server b/cppe/demo/IceE/callback/config.server
new file mode 100644
index 00000000000..d9c7154678a
--- /dev/null
+++ b/cppe/demo/IceE/callback/config.server
@@ -0,0 +1,29 @@
+#
+# The server creates one single object adapter with the name
+# "Callback.Server". The following line sets the endpoints for this
+# adapter.
+#
+Callback.Server.Endpoints=tcp -p 10000
+
+#
+# Warn about connection exceptions
+#
+Ice.Warn.Connections=1
+
+#
+# Network Tracing
+#
+# 0 = no network tracing
+# 1 = trace connection establishment and closure
+# 2 = like 1, but more detailed
+# 3 = like 2, but also trace data transfer
+#
+#Ice.Trace.Network=1
+
+#
+# Protocol Tracing
+#
+# 0 = no protocol tracing
+# 1 = trace protocol messages
+#
+#Ice.Trace.Protocol=1
diff --git a/cppe/demo/IceE/chat/ChatClient.cpp b/cppe/demo/IceE/chat/ChatClient.cpp
index f8acfe634cd..0f4be3f31d3 100644
--- a/cppe/demo/IceE/chat/ChatClient.cpp
+++ b/cppe/demo/IceE/chat/ChatClient.cpp
@@ -52,9 +52,9 @@ BOOL CChatClientApp::InitInstance()
LogIPtr log;
try
{
- Ice::InitializationData initData;
+ Ice::InitializationData initData;
log = new LogI;
- initData.logger = log;
+ initData.logger = log;
int argc = 0;
communicator = Ice::initialize(argc, 0, initData);
diff --git a/cppe/demo/IceE/chat/ChatClientDlg.cpp b/cppe/demo/IceE/chat/ChatClientDlg.cpp
index 216a77ba4d9..6bb3f13d32c 100644
--- a/cppe/demo/IceE/chat/ChatClientDlg.cpp
+++ b/cppe/demo/IceE/chat/ChatClientDlg.cpp
@@ -35,17 +35,15 @@ public:
virtual void
message(const string& data, const Ice::Current&)
{
- _log->message(data);
+ _log->message(data);
}
private:
const LogIPtr _log;
-
};
-CChatClientDlg::CChatClientDlg(const Ice::CommunicatorPtr& communicator, const LogIPtr& log,
- CWnd* pParent /*=NULL*/) :
+CChatClientDlg::CChatClientDlg(const Ice::CommunicatorPtr& communicator, const LogIPtr& log, CWnd* pParent /*=NULL*/) :
CDialog(CChatClientDlg::IDD, pParent),
_communicator(communicator),
_chat(0),
@@ -53,7 +51,7 @@ CChatClientDlg::CChatClientDlg(const Ice::CommunicatorPtr& communicator, const L
//_user(""), // For ease of testing these can be filled in.
//_password(""),
//_host(""),
- _port("10005")
+ _port("4063")
{
_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
@@ -66,9 +64,9 @@ CChatClientDlg::~CChatClientDlg()
//
if(_ping)
{
- _ping->destroy();
- _ping->getThreadControl().join();
- _ping = 0;
+ _ping->destroy();
+ _ping->getThreadControl().join();
+ _ping = 0;
}
}
@@ -108,9 +106,9 @@ CChatClientDlg::setDialogState()
if(_chat == 0)
{
- //
- // Logged out: Disable all except Login.
- //
+ //
+ // Logged out: Disable all except Login.
+ //
_edit->EnableWindow(FALSE);
_display->EnableWindow(FALSE);
sendWnd->EnableWindow(FALSE);
@@ -120,23 +118,23 @@ CChatClientDlg::setDialogState()
configWnd->SetWindowText("Login");
#endif
- //
- // Set the focus to the login button
- //
- loginWnd->SetFocus();
-
- //
- // Set the default button.
- //
- sendWnd->SendMessage(BM_SETSTYLE, (WPARAM)BS_PUSHBUTTON, (LPARAM)TRUE);
- SendMessage(DM_SETDEFID, (WPARAM)IDC_CONFIG, 0);
- configWnd->SendMessage(BM_SETSTYLE, (WPARAM)BS_DEFPUSHBUTTON, (LPARAM)TRUE);
+ //
+ // Set the focus to the login button
+ //
+ loginWnd->SetFocus();
+
+ //
+ // Set the default button.
+ //
+ sendWnd->SendMessage(BM_SETSTYLE, (WPARAM)BS_PUSHBUTTON, (LPARAM)TRUE);
+ SendMessage(DM_SETDEFID, (WPARAM)IDC_CONFIG, 0);
+ configWnd->SendMessage(BM_SETSTYLE, (WPARAM)BS_DEFPUSHBUTTON, (LPARAM)TRUE);
}
else
{
//
- // Logged in: Enable all and change Login to Logout
- //
+ // Logged in: Enable all and change Login to Logout
+ //
_edit->EnableWindow(TRUE);
_display->EnableWindow(TRUE);
sendWnd->EnableWindow(TRUE);
@@ -147,12 +145,12 @@ CChatClientDlg::setDialogState()
#endif
_edit->SetFocus();
- //
- // Set the default button.
- //
- configWnd->SendMessage(BM_SETSTYLE, (WPARAM)BS_PUSHBUTTON, (LPARAM)TRUE);
- SendMessage(DM_SETDEFID, (WPARAM)IDC_SEND, 0);
- sendWnd->SendMessage(BM_SETSTYLE, (WPARAM)BS_DEFPUSHBUTTON, (LPARAM)TRUE);
+ //
+ // Set the default button.
+ //
+ configWnd->SendMessage(BM_SETSTYLE, (WPARAM)BS_PUSHBUTTON, (LPARAM)TRUE);
+ SendMessage(DM_SETDEFID, (WPARAM)IDC_SEND, 0);
+ sendWnd->SendMessage(BM_SETSTYLE, (WPARAM)BS_DEFPUSHBUTTON, (LPARAM)TRUE);
}
}
@@ -195,24 +193,24 @@ CChatClientDlg::OnCancel()
{
if(_chat)
{
- //
- // Clear the router.
- //
- assert(_router);
- try
- {
- _router->destroySession();
- }
+ //
+ // Clear the router.
+ //
+ assert(_router);
+ try
+ {
+ _router->destroySession();
+ }
catch(const Ice::ConnectionLostException&)
{
//
// Expected: the router closed the connection.
//
}
- catch(const Ice::Exception& ex)
- {
- AfxMessageBox(CString(ex.toString().c_str()), MB_OK|MB_ICONEXCLAMATION);
- }
+ catch(const Ice::Exception& ex)
+ {
+ AfxMessageBox(CString(ex.toString().c_str()), MB_OK|MB_ICONEXCLAMATION);
+ }
}
_log->setHandle(0);
@@ -283,15 +281,15 @@ CChatClientDlg::OnSend()
text.TrimRight();
if(text.IsEmpty())
{
- return;
+ return;
}
try
{
#ifdef _WIN32_WCE
- char buffer[256];
- wcstombs(buffer, text, 256);
- _chat->say(buffer);
+ char buffer[256];
+ wcstombs(buffer, text, 256);
+ _chat->say(buffer);
#else
_chat->say(string(text));
#endif
@@ -300,10 +298,10 @@ CChatClientDlg::OnSend()
{
AfxMessageBox(CString(e.toString().c_str()), MB_OK|MB_ICONEXCLAMATION);
- _ping->destroy();
- _ping->getThreadControl().join();
+ _ping->destroy();
+ _ping->getThreadControl().join();
- EndDialog(0);
+ EndDialog(0);
}
//
@@ -319,129 +317,127 @@ CChatClientDlg::OnLogin()
if(_chat == 0)
{
//
- // Login: Create and display login dialog.
- //
+ // Login: Create and display login dialog.
+ //
CChatConfigDlg dlg(_user, _password, _host, _port);
if(dlg.DoModal() == IDOK)
- {
- _user = dlg.getUser();
- _password = dlg.getPassword();
- _host = dlg.getHost();
- _port = dlg.getPort();
-
- string user;
- string password;
- string host;
- string port;
+ {
+ _user = dlg.getUser();
+ _password = dlg.getPassword();
+ _host = dlg.getHost();
+ _port = dlg.getPort();
+
+ string user;
+ string password;
+ string host;
+ string port;
#ifdef _WIN32_WCE
- char buffer[64];
- wcstombs(buffer, _user, 64);
- user = buffer;
+ char buffer[64];
+ wcstombs(buffer, _user, 64);
+ user = buffer;
- wcstombs(buffer, _password, 64);
- password = buffer;
+ wcstombs(buffer, _password, 64);
+ password = buffer;
- wcstombs(buffer, _host, 64);
- host = buffer;
+ wcstombs(buffer, _host, 64);
+ host = buffer;
- wcstombs(buffer, _port, 64);
- port = buffer;
+ wcstombs(buffer, _port, 64);
+ port = buffer;
#else
- user = _user;
- password = _password;
- host = _host;
- port = _port;
+ user = _user;
+ password = _password;
+ host = _host;
+ port = _port;
#endif
- try
- {
- string routerStr =
- Ice::printfToString("DemoGlacier2/router:tcp -p %s -h %s", port.c_str(), host.c_str());
- _router = Glacier2::RouterPrx::checkedCast(_communicator->stringToProxy(routerStr));
- assert(_router);
-
- //
- // Now setup the new router.
- //
- _chat = ChatSessionPrx::uncheckedCast(_router->createSession(user, password)->ice_router(_router));
-
-
- //
- // Create the OA.
- //
- _adapter = _communicator->createObjectAdapterWithRouter("Chat.Client", _router);
- _adapter->activate();
-
- //
- // Create the callback object. This must have the
- // category as defined by the Glacier2 session.
- //
- string category = _router->getServerProxy()->ice_getIdentity().category;
- Ice::Identity callbackReceiverIdent;
- callbackReceiverIdent.name = "callbackReceiver";
- callbackReceiverIdent.category = category;
- _callback = ChatCallbackPrx::uncheckedCast(
- _adapter->add(new ChatCallbackI(_log), callbackReceiverIdent));
-
- _chat->setCallback(_callback);
-
- //
- // Create a ping thread to keep the session alive.
- //
- _ping = new SessionPingThread(_chat, (long)_router->getSessionTimeout() / 2);
- _ping->start();
- }
- catch(const Glacier2::CannotCreateSessionException& ex)
- {
- AfxMessageBox(CString(ex.reason.c_str()), MB_OK|MB_ICONEXCLAMATION);
- }
- catch(const Ice::Exception& ex)
- {
- AfxMessageBox(CString(ex.toString().c_str()), MB_OK|MB_ICONEXCLAMATION);
- _chat = 0;
- }
- }
+ try
+ {
+ string routerStr =
+ Ice::printfToString("DemoGlacier2/router:tcp -p %s -h %s", port.c_str(), host.c_str());
+ _router = Glacier2::RouterPrx::checkedCast(_communicator->stringToProxy(routerStr));
+ assert(_router);
+
+ //
+ // Now setup the new router.
+ //
+ _chat = ChatSessionPrx::uncheckedCast(_router->createSession(user, password)->ice_router(_router));
+
+ //
+ // Create the OA.
+ //
+ _adapter = _communicator->createObjectAdapterWithRouter("Chat.Client", _router);
+ _adapter->activate();
+
+ //
+ // Create the callback object. This must have the
+ // category as defined by the Glacier2 session.
+ //
+ Ice::Identity callbackReceiverIdent;
+ callbackReceiverIdent.name = "callbackReceiver";
+ callbackReceiverIdent.category = _router->getCallbackForClient();
+ ChatCallbackPtr cb = new ChatCallbackI(_log);
+ _callback = ChatCallbackPrx::uncheckedCast(_adapter->add(cb, callbackReceiverIdent));
+
+ _chat->setCallback(_callback);
+
+ //
+ // Create a ping thread to keep the session alive.
+ //
+ _ping = new SessionPingThread(_chat, (long)_router->getSessionTimeout() / 2);
+ _ping->start();
+ }
+ catch(const Glacier2::CannotCreateSessionException& ex)
+ {
+ AfxMessageBox(CString(ex.reason.c_str()), MB_OK|MB_ICONEXCLAMATION);
+ }
+ catch(const Ice::Exception& ex)
+ {
+ AfxMessageBox(CString(ex.toString().c_str()), MB_OK|MB_ICONEXCLAMATION);
+ _chat = 0;
+ }
+ }
}
else
{
//
- // Logout: Destroy session and stop ping thread.
- //
- assert(_callback);
- _adapter->remove(_callback->ice_getIdentity());
- _callback = 0;
-
- assert(_chat);
- _chat = 0;
-
- //
- // Destroy the ping thread.
- //
- _ping->destroy();
- _ping->getThreadControl().join();
- _ping = 0;
-
- //
- // Clear the router.
- //
- assert(_router);
- try
- {
- _router->destroySession();
- }
+ // Logout: Destroy session and stop ping thread.
+ //
+ assert(_callback);
+ _adapter->remove(_callback->ice_getIdentity());
+ _callback = 0;
+
+ assert(_chat);
+ _chat = 0;
+
+ //
+ // Destroy the ping thread.
+ //
+ _ping->destroy();
+ _ping->getThreadControl().join();
+ _ping = 0;
+
+ //
+ // Clear the router.
+ //
+ assert(_router);
+ try
+ {
+ _router->destroySession();
+ }
catch(const Ice::ConnectionLostException&)
{
//
// Expected: the router closed the connection.
//
}
- catch(const Ice::Exception& ex)
- {
- AfxMessageBox(CString(ex.toString().c_str()), MB_OK|MB_ICONEXCLAMATION);
- }
+ catch(const Ice::Exception& ex)
+ {
+ AfxMessageBox(CString(ex.toString().c_str()), MB_OK|MB_ICONEXCLAMATION);
+ }
- _adapter->destroy();
- _router = 0;
+ _adapter->destroy();
+ _router = 0;
}
//
diff --git a/cppe/demo/IceE/chat/ChatConfigDlg.cpp b/cppe/demo/IceE/chat/ChatConfigDlg.cpp
index 5ff7993880a..3849f12bc6c 100644
--- a/cppe/demo/IceE/chat/ChatConfigDlg.cpp
+++ b/cppe/demo/IceE/chat/ChatConfigDlg.cpp
@@ -19,7 +19,7 @@
using namespace std;
CChatConfigDlg::CChatConfigDlg(const CString& user, const CString& password,
- const CString& host, const CString& port, CWnd* pParent /*=NULL*/) :
+ const CString& host, const CString& port, CWnd* pParent /*=NULL*/) :
CDialog(CChatConfigDlg::IDD, pParent),
_user(user),
_password(password),
diff --git a/cppe/demo/IceE/chat/Client.cpp b/cppe/demo/IceE/chat/Client.cpp
index 78b09f415bd..7559dd37ae4 100644
--- a/cppe/demo/IceE/chat/Client.cpp
+++ b/cppe/demo/IceE/chat/Client.cpp
@@ -24,7 +24,7 @@ public:
virtual void
message(const string& data, const Ice::Current&)
{
- printf("%s\n", data.c_str());
+ printf("%s\n", data.c_str());
}
};
@@ -46,6 +46,23 @@ trim(const string& s)
return s;
}
+void
+cleanup(const Glacier2::RouterPrx& router, const SessionPingThreadPtr& ping)
+{
+ try
+ {
+ router->destroySession();
+ }
+ catch(const Ice::ConnectionLostException&)
+ {
+ //
+ // Expected: the router closed the connection.
+ //
+ }
+ ping->destroy();
+ ping->getThreadControl().join();
+}
+
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
@@ -63,12 +80,10 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
}
Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(defaultRouter);
+ if(!router)
{
- if(!router)
- {
- fprintf(stderr, "%s: configured router is not a Glacier2 router\n", argv[0]);
- return EXIT_FAILURE;
- }
+ fprintf(stderr, "%s: configured router is not a Glacier2 router\n", argv[0]);
+ return EXIT_FAILURE;
}
char buffer[1024];
@@ -76,40 +91,39 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
ChatSessionPrx session;
while(true)
{
- printf("This demo accepts any user-id / password combination.\n");
+ printf("This demo accepts any user-id / password combination.\n");
printf("user id: ");
- fgets(buffer, 1024, stdin);
- string id(buffer);
+ fgets(buffer, 1024, stdin);
+ string id(buffer);
id = trim(id);
printf("password: ");
- fgets(buffer, 1024, stdin);
- string pw(buffer);
+ fgets(buffer, 1024, stdin);
+ string pw(buffer);
pw = trim(pw);
try
{
- session = ChatSessionPrx::uncheckedCast(router->createSession(id, pw));
- break;
+ session = ChatSessionPrx::uncheckedCast(router->createSession(id, pw));
+ break;
}
catch(const Glacier2::PermissionDeniedException& ex)
{
- fprintf(stderr, "permission denied:\n%s", ex.toString().c_str());
+ fprintf(stderr, "permission denied:\n%s", ex.toString().c_str());
}
}
SessionPingThreadPtr ping = new SessionPingThread(session, (long)router->getSessionTimeout() / 2);
ping->start();
- string category = router->getServerProxy()->ice_getIdentity().category;
Ice::Identity callbackReceiverIdent;
callbackReceiverIdent.name = "callbackReceiver";
- callbackReceiverIdent.category = category;
+ callbackReceiverIdent.category = router->getCategoryForClient();
- Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Chat.Client");
- ChatCallbackPrx callback = ChatCallbackPrx::uncheckedCast(
- adapter->add(new ChatCallbackI, callbackReceiverIdent));
+ Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithRouter("Chat.Client", defaultRouter);
+ ChatCallbackPtr cb = new ChatCallbackI;
+ ChatCallbackPrx callback = ChatCallbackPrx::uncheckedCast(adapter->add(cb, callbackReceiverIdent));
adapter->activate();
session->setCallback(callback);
@@ -120,54 +134,42 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
do
{
- printf("==> ");
- char* ret = fgets(buffer, 1024, stdin);
- if(ret == NULL)
- {
- break;
- }
-
- string s(buffer);
- s = trim(s);
- if(!s.empty())
- {
- if(s[0] == '/')
- {
- if(s == "/quit")
- {
- break;
- }
- menu();
- }
- else
- {
- session->say(s);
- }
- }
- }
- while(true);
-
- try
- {
- router->destroySession();
- }
- catch(const Ice::ConnectionLostException&)
- {
- //
- // Expected: the router closed the connection.
- //
- }
+ printf("==> ");
+ char* ret = fgets(buffer, 1024, stdin);
+ if(ret == NULL)
+ {
+ break;
+ }
+
+ string s(buffer);
+ s = trim(s);
+ if(!s.empty())
+ {
+ if(s[0] == '/')
+ {
+ if(s == "/quit")
+ {
+ break;
+ }
+ menu();
+ }
+ else
+ {
+ session->say(s);
+ }
+ }
+ }
+ while(true);
+
+ cleanup(router, ping);
}
catch(const Ice::Exception& ex)
{
fprintf(stderr, "%s\n", ex.toString().c_str());
- ping->destroy();
- ping->getThreadControl().join();
+ cleanup(router, ping);
+
return EXIT_FAILURE;
}
-
- ping->destroy();
- ping->getThreadControl().join();
return EXIT_SUCCESS;
}
diff --git a/cppe/demo/IceE/chat/LogI.cpp b/cppe/demo/IceE/chat/LogI.cpp
index dbed3ad13c9..7577334bb12 100644
--- a/cppe/demo/IceE/chat/LogI.cpp
+++ b/cppe/demo/IceE/chat/LogI.cpp
@@ -65,7 +65,7 @@ LogI::message(const string& msg)
string line = msg + "\r\n";
if(_hwnd)
{
- post(line);
+ post(line);
}
else
{
@@ -79,7 +79,7 @@ LogI::setHandle(HWND hwnd)
_hwnd = hwnd;
if(_hwnd != 0 && !_buffer.empty())
{
- post(_buffer);
+ post(_buffer);
_buffer.clear();
}
}
diff --git a/cppe/demo/IceE/chat/README b/cppe/demo/IceE/chat/README
index 9204b31ccc2..fd026868442 100644
--- a/cppe/demo/IceE/chat/README
+++ b/cppe/demo/IceE/chat/README
@@ -16,11 +16,11 @@ public interface instead of the loopback interface.
For most configurations the property can be changed from:
-Glacier2.Client.Endpoints=ssl -p 10005 -h 127.0.0.1
+Glacier2.Client.Endpoints=ssl -p 4064 -h 127.0.0.1
to:
-Glacier2.Client.Endpoints=tcp -p 10005
+Glacier2.Client.Endpoints=tcp -p 4063
Next, start the Glacier2 router:
diff --git a/cppe/demo/IceE/chat/Router.ice b/cppe/demo/IceE/chat/Router.ice
index 5f22e1081bf..a8d117da000 100644
--- a/cppe/demo/IceE/chat/Router.ice
+++ b/cppe/demo/IceE/chat/Router.ice
@@ -107,7 +107,7 @@ interface Router extends Ice::Router
*
**/
Session* createSession(string userId, string password)
- throws PermissionDeniedException, CannotCreateSessionException;
+ throws PermissionDeniedException, CannotCreateSessionException;
/**
*
@@ -118,7 +118,7 @@ interface Router extends Ice::Router
*
**/
void destroySession()
- throws SessionNotExistException;
+ throws SessionNotExistException;
/**
*
diff --git a/cppe/demo/IceE/chat/Session.ice b/cppe/demo/IceE/chat/Session.ice
index f2fb6861fc3..f1f9c39b54d 100644
--- a/cppe/demo/IceE/chat/Session.ice
+++ b/cppe/demo/IceE/chat/Session.ice
@@ -224,7 +224,7 @@ interface SessionManager
*
**/
Session* create(string userId, SessionControl* control)
- throws CannotCreateSessionException;
+ throws CannotCreateSessionException;
};
};
diff --git a/cppe/demo/IceE/chat/config b/cppe/demo/IceE/chat/config
index 83d3000811e..e6dec3e0505 100644
--- a/cppe/demo/IceE/chat/config
+++ b/cppe/demo/IceE/chat/config
@@ -2,14 +2,7 @@
# The proxy to the Glacier2 router for all outgoing connections. This
# must match the value of Glacier2.Client.Endpoints in config.glacier2.
#
-Ice.Default.Router=DemoGlacier2/router:tcp -p 10005 -h 127.0.0.1
-
-#
-# The proxy for the Glacier2 router, installed in the client's
-# object adapter named Chat.Client. This router proxy must
-# match the value of Glacier2.Client.Endpoints.
-#
-Chat.Client.Router=DemoGlacier2/router:tcp -p 10005 -h 127.0.0.1
+Ice.Default.Router=DemoGlacier2/router:tcp -p 4063 -h 127.0.0.1
#
# We don't need any endpoints for the client if we use a
@@ -25,9 +18,24 @@ Chat.Client.Endpoints=
Ice.RetryIntervals=-1
#
-# Other settings.
+# Warn about connection exceptions
#
+#Ice.Warn.Connections=1
+#
+# Network Tracing
+#
+# 0 = no network tracing
+# 1 = trace connection establishment and closure
+# 2 = like 1, but more detailed
+# 3 = like 2, but also trace data transfer
+#
#Ice.Trace.Network=1
+
+#
+# Protocol Tracing
+#
+# 0 = no protocol tracing
+# 1 = trace protocol messages
+#
#Ice.Trace.Protocol=1
-#Ice.Warn.Connections=1
diff --git a/cppe/demo/IceE/chat/stdafx.h b/cppe/demo/IceE/chat/stdafx.h
index 64165af5a41..7316cf46505 100644
--- a/cppe/demo/IceE/chat/stdafx.h
+++ b/cppe/demo/IceE/chat/stdafx.h
@@ -51,21 +51,21 @@
#endif // _WIN32_WCE
#ifndef VC_EXTRALEAN
-#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
+#define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers
#endif
#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#if defined(_WIN32_WCE) && (_WIN32_WCE >= 211) && (_AFXDLL)
-#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
+#include <afxdtctl.h> // MFC support for Internet Explorer 4 Common Controls
#endif
#ifndef _AFX_NO_AFXCMN_SUPPORT
-#include <afxcmn.h> // MFC support for Windows Common Controls
+#include <afxcmn.h> // MFC support for Windows Common Controls
#endif // _AFX_NO_AFXCMN_SUPPORT
-#include <afxsock.h> // MFC socket extensions
+#include <afxsock.h> // MFC socket extensions
//{{AFX_INSERT_LOCATION}}
// Microsoft eMbedded Visual C++ will insert additional declarations immediately before the previous line.
diff --git a/cppe/demo/IceE/hello/Client.cpp b/cppe/demo/IceE/hello/Client.cpp
index f2174d5e25b..f739944e5e2 100644
--- a/cppe/demo/IceE/hello/Client.cpp
+++ b/cppe/demo/IceE/hello/Client.cpp
@@ -44,16 +44,16 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
{
- fprintf(stderr, "%s: property `%s' not set\n", argv[0], proxyProperty);
- return EXIT_FAILURE;
+ fprintf(stderr, "%s: property `%s' not set\n", argv[0], proxyProperty);
+ return EXIT_FAILURE;
}
Ice::ObjectPrx base = communicator->stringToProxy(proxy);
HelloPrx twoway = HelloPrx::checkedCast(base->ice_twoway()->ice_timeout(-1));
if(!twoway)
{
- fprintf(stderr, "%s: invalid proxy\n", argv[0]);
- return EXIT_FAILURE;
+ fprintf(stderr, "%s: invalid proxy\n", argv[0]);
+ return EXIT_FAILURE;
}
HelloPrx oneway = HelloPrx::uncheckedCast(twoway->ice_oneway());
#ifdef ICEE_HAS_BATCH
@@ -68,99 +68,99 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
char c = EOF;
do
{
- try
- {
- printf("==> ");
- do
- {
- c = getchar();
- }
- while(c != EOF && c == '\n');
- if(c == 't')
- {
- twoway->sayHello(delay);
- }
- else if(c == 'o')
- {
- oneway->sayHello(delay);
- }
+ try
+ {
+ printf("==> ");
+ do
+ {
+ c = getchar();
+ }
+ while(c != EOF && c == '\n');
+ if(c == 't')
+ {
+ twoway->sayHello(delay);
+ }
+ else if(c == 'o')
+ {
+ oneway->sayHello(delay);
+ }
#ifdef ICEE_HAS_BATCH
- else if(c == 'O')
- {
- batchOneway->sayHello(delay);
- }
- else if(c == 'f')
- {
- communicator->flushBatchRequests();
- }
+ else if(c == 'O')
+ {
+ batchOneway->sayHello(delay);
+ }
+ else if(c == 'f')
+ {
+ communicator->flushBatchRequests();
+ }
#endif
- 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));
+ 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));
#ifdef ICEE_HAS_BATCH
- batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_timeout(timeout));
-#endif
- if(timeout == -1)
- {
- printf("timeout is now switched off\n");
- }
- else
- {
- printf("timeout is now set to 2000ms\n");
- }
- }
- else if(c == 'P')
- {
- if(delay == 0)
- {
- delay = 2500;
- }
- else
- {
- delay = 0;
- }
-
- if(delay == 0)
- {
- printf("server delay is now deactivated\n");
- }
- else
- {
- printf("server delay is now set to 2500ms\n");
- }
- }
- else if(c == 's')
- {
- twoway->shutdown();
- }
- else if(c == 'x')
- {
- // Nothing to do
- }
- else if(c == '?')
- {
- menu();
- }
- else
- {
- printf("unknown command `%c'\n", c);
- menu();
- }
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- }
+ batchOneway = HelloPrx::uncheckedCast(batchOneway->ice_timeout(timeout));
+#endif
+ if(timeout == -1)
+ {
+ printf("timeout is now switched off\n");
+ }
+ else
+ {
+ printf("timeout is now set to 2000ms\n");
+ }
+ }
+ else if(c == 'P')
+ {
+ if(delay == 0)
+ {
+ delay = 2500;
+ }
+ else
+ {
+ delay = 0;
+ }
+
+ if(delay == 0)
+ {
+ printf("server delay is now deactivated\n");
+ }
+ else
+ {
+ printf("server delay is now set to 2500ms\n");
+ }
+ }
+ else if(c == 's')
+ {
+ twoway->shutdown();
+ }
+ else if(c == 'x')
+ {
+ // Nothing to do
+ }
+ else if(c == '?')
+ {
+ menu();
+ }
+ else
+ {
+ printf("unknown command `%c'\n", c);
+ menu();
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ }
}
while(c != EOF && c != 'x');
@@ -175,29 +175,29 @@ main(int argc, char* argv[])
try
{
- Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
- initData.properties->load("config");
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
+ Ice::InitializationData initData;
+ initData.properties = Ice::createProperties();
+ initData.properties->load("config.client");
+ communicator = Ice::initialize(argc, argv, initData);
+ status = run(argc, argv, communicator);
}
catch(const Ice::Exception& ex)
{
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
+ }
}
return status;
diff --git a/cppe/demo/IceE/hello/Server.cpp b/cppe/demo/IceE/hello/Server.cpp
index e428c1c9dfa..313cb6a9948 100644
--- a/cppe/demo/IceE/hello/Server.cpp
+++ b/cppe/demo/IceE/hello/Server.cpp
@@ -22,7 +22,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
}
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Hello");
- Ice::ObjectPtr object = new HelloI;
+ Demo::HelloPtr object = new HelloI;
adapter->add(object, communicator->stringToIdentity("hello"));
adapter->activate();
communicator->waitForShutdown();
@@ -38,29 +38,29 @@ main(int argc, char* argv[])
try
{
Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
- initData.properties->load("config");
- initData.properties->setProperty("Ice.Override.Timeout", "100");
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
+ initData.properties = Ice::createProperties();
+ initData.properties->load("config.server");
+ initData.properties->setProperty("Ice.Override.Timeout", "100");
+ communicator = Ice::initialize(argc, argv, initData);
+ status = run(argc, argv, communicator);
}
catch(const Ice::Exception& ex)
{
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
+ }
}
return status;
diff --git a/cppe/demo/IceE/hello/config b/cppe/demo/IceE/hello/config.client
index 99491820ac2..0cea3d3bc26 100644
--- a/cppe/demo/IceE/hello/config
+++ b/cppe/demo/IceE/hello/config.client
@@ -5,16 +5,9 @@
Hello.Proxy=hello:tcp -p 10000
#
-# The server creates one single object adapter with the name
-# "Hello". The following line sets the endpoints for this
-# adapter.
-#
-Hello.Endpoints=tcp -p 10000
-
-#
# Warn about connection exceptions
#
-#Ice.Warn.Connections=1
+Ice.Warn.Connections=1
#
# Network Tracing
@@ -24,7 +17,7 @@ Hello.Endpoints=tcp -p 10000
# 2 = like 1, but more detailed
# 3 = like 2, but also trace data transfer
#
-Ice.Trace.Network=0
+#Ice.Trace.Network=1
#
# Protocol Tracing
@@ -32,4 +25,4 @@ Ice.Trace.Network=0
# 0 = no protocol tracing
# 1 = trace protocol messages
#
-Ice.Trace.Protocol=0
+#Ice.Trace.Protocol=1
diff --git a/cppe/demo/IceE/minimal/config b/cppe/demo/IceE/hello/config.server
index 9a0c897c2d4..147d3c96ade 100644
--- a/cppe/demo/IceE/minimal/config
+++ b/cppe/demo/IceE/hello/config.server
@@ -1,10 +1,4 @@
#
-# The client reads this property to create the reference to the
-# "hello" object in the server.
-#
-Hello.Proxy=hello:tcp -p 10000
-
-#
# The server creates one single object adapter with the name
# "Hello". The following line sets the endpoints for this
# adapter.
@@ -24,7 +18,7 @@ Ice.Warn.Connections=1
# 2 = like 1, but more detailed
# 3 = like 2, but also trace data transfer
#
-Ice.Trace.Network=0
+#Ice.Trace.Network=1
#
# Protocol Tracing
@@ -32,4 +26,4 @@ Ice.Trace.Network=0
# 0 = no protocol tracing
# 1 = trace protocol messages
#
-Ice.Trace.Protocol=0
+#Ice.Trace.Protocol=1
diff --git a/cppe/demo/IceE/latency/Client.cpp b/cppe/demo/IceE/latency/Client.cpp
index 919ec2375bb..7d2230d259f 100644
--- a/cppe/demo/IceE/latency/Client.cpp
+++ b/cppe/demo/IceE/latency/Client.cpp
@@ -23,20 +23,20 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
}
Ice::PropertiesPtr properties = communicator->getProperties();
- const char* proxyProperty = "Latency.Proxy";
+ const char* proxyProperty = "Ping.Proxy";
string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
{
- fprintf(stderr, "%s: property `%s' not set\n", argv[0], proxyProperty);
- return EXIT_FAILURE;
+ fprintf(stderr, "%s: property `%s' not set\n", argv[0], proxyProperty);
+ return EXIT_FAILURE;
}
Ice::ObjectPrx base = communicator->stringToProxy(proxy);
PingPrx ping = PingPrx::checkedCast(base);
if(!ping)
{
- fprintf(stderr, "%s: invalid proxy\n", argv[0]);
- return EXIT_FAILURE;
+ fprintf(stderr, "%s: invalid proxy\n", argv[0]);
+ return EXIT_FAILURE;
}
// Initial ping to setup the connection.
@@ -48,7 +48,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
printf("pinging server %d times (this may take a while)\n", repetitions);
for(int i = 0; i < repetitions; ++i)
{
- ping->ice_ping();
+ ping->ice_ping();
}
tm = IceUtil::Time::now() - tm;
@@ -68,28 +68,28 @@ main(int argc, char* argv[])
try
{
Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
- initData.properties->load("config");
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
+ initData.properties = Ice::createProperties();
+ initData.properties->load("config.client");
+ communicator = Ice::initialize(argc, argv, initData);
+ status = run(argc, argv, communicator);
}
catch(const Ice::Exception& ex)
{
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
+ }
}
return status;
diff --git a/cppe/demo/IceE/latency/Server.cpp b/cppe/demo/IceE/latency/Server.cpp
index d2abde441e3..c588ba75985 100644
--- a/cppe/demo/IceE/latency/Server.cpp
+++ b/cppe/demo/IceE/latency/Server.cpp
@@ -13,12 +13,6 @@
using namespace std;
using namespace Demo;
-class PingI : public Ping
-{
-public:
- // no methods.
-};
-
int
run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
{
@@ -29,7 +23,8 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
}
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Latency");
- adapter->add(new PingI, communicator->stringToIdentity("ping"));
+ Ice::ObjectPtr object = new Ping;
+ adapter->add(object, communicator->stringToIdentity("ping"));
adapter->activate();
communicator->waitForShutdown();
return EXIT_SUCCESS;
@@ -44,28 +39,28 @@ main(int argc, char* argv[])
try
{
Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
- initData.properties->load("config");
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
+ initData.properties = Ice::createProperties();
+ initData.properties->load("config.server");
+ communicator = Ice::initialize(argc, argv, initData);
+ status = run(argc, argv, communicator);
}
catch(const Ice::Exception& ex)
{
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
+ }
}
return status;
diff --git a/cppe/demo/IceE/latency/WinCEClient.cpp b/cppe/demo/IceE/latency/WinCEClient.cpp
index 753150d5c9b..70542c2bd11 100644
--- a/cppe/demo/IceE/latency/WinCEClient.cpp
+++ b/cppe/demo/IceE/latency/WinCEClient.cpp
@@ -23,35 +23,35 @@ WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
case WM_CREATE:
{
- RECT rcClient;
- GetClientRect(hWnd, &rcClient);
- editHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"",
- WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE,
- 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
- hWnd, (HMENU)101, GetModuleHandle(NULL), NULL);
- assert(editHwnd != NULL);
+ RECT rcClient;
+ GetClientRect(hWnd, &rcClient);
+ editHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"",
+ WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE,
+ 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
+ hWnd, (HMENU)101, GetModuleHandle(NULL), NULL);
+ assert(editHwnd != NULL);
}
break;
case WM_SIZE:
{
- RECT rcClient;
- GetClientRect(hWnd, &rcClient);
- SetWindowPos(editHwnd, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
+ RECT rcClient;
+ GetClientRect(hWnd, &rcClient);
+ SetWindowPos(editHwnd, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
}
break;
case WM_CLOSE:
- DestroyWindow(hWnd);
- break;
+ DestroyWindow(hWnd);
+ break;
case WM_DESTROY:
- wmDestroy = true;
- PostQuitMessage(0);
- break;
+ wmDestroy = true;
+ PostQuitMessage(0);
+ break;
default:
- return DefWindowProc(hWnd, msg, wParam, lParam);
+ return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
@@ -62,21 +62,21 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
static const TCHAR windowClassName[] = L"Latency Client";
WNDCLASS wc;
- wc.style = CS_HREDRAW|CS_VREDRAW;
- wc.lpfnWndProc = (WNDPROC)WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(NULL, 0);
- wc.hCursor = 0;
- wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.style = CS_HREDRAW|CS_VREDRAW;
+ wc.lpfnWndProc = (WNDPROC)WndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIcon(NULL, 0);
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = windowClassName;
if(!RegisterClass(&wc))
{
- MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
- return 0;
+ MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
+ return 0;
}
RECT rect;
@@ -84,20 +84,20 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
int width = rect.right - rect.left;
if(width > 320)
{
- width = 320;
+ width = 320;
}
int height = rect.bottom - rect.top;
if(height > 200)
{
- height = 200;
+ height = 200;
}
HWND mainWnd = CreateWindow(windowClassName, L"Latency Client", WS_VISIBLE|WS_OVERLAPPED|WS_SYSMENU|WS_SIZEBOX,
- CW_USEDEFAULT, CW_USEDEFAULT, width, height,
- NULL, NULL, hInstance, NULL);
+ CW_USEDEFAULT, CW_USEDEFAULT, width, height,
+ NULL, NULL, hInstance, NULL);
if(mainWnd == NULL)
{
- MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
- return 0;
+ MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
+ return 0;
}
ShowWindow(mainWnd, SW_SHOW);
@@ -109,110 +109,110 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
try
{
Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
-
- //
- // Set a default value for Latency.Proxy so that the demo will
- // run without a configuration file.
- //
- initData.properties->setProperty("Latency.Proxy", "ping:tcp -p 10000");
-
- //
- // Now, load the configuration file if present. Under WinCE we
- // use "config.txt" since it can be edited with pocket word.
- //
- try
- {
- initData.properties->load("config.txt");
- }
- catch(const Ice::FileException&)
- {
- }
-
- communicator = Ice::initialize(__argc, __argv, initData);
-
- const char* proxyProperty = "Latency.Proxy";
- string proxy = initData.properties->getProperty(proxyProperty);
-
- PingPrx ping = PingPrx::checkedCast(communicator->stringToProxy(proxy));
- if(!ping)
- {
- MessageBox(NULL, L"invalid proxy", L"Latency Client", MB_ICONEXCLAMATION | MB_OK);
- return EXIT_FAILURE;
- }
-
- // Initial ping to setup the connection.
- ping->ice_ping();
-
- IceUtil::Time tm = IceUtil::Time::now();
-
- const int repetitions = 10000;
- wchar_t buf[1000];
- wsprintf(buf, L"pinging server %d times (this may take a while)\r\n", repetitions);
- ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)buf);
- for(int i = 0; i < repetitions; ++i)
- {
- ping->ice_ping();
- if((i % 100) == 0)
- {
- ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)L".");
- //
- // Run the message pump just in case the user tries to close the app.
- //
- MSG Msg;
- while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
- if(wmDestroy)
- {
- break;
- }
- }
- }
-
- tm = IceUtil::Time::now() - tm;
-
- wsprintf(buf, L"\r\ntime for %d pings: %fms\r\ntime per ping: %fms\r\n",
- repetitions, tm.toMilliSecondsDouble(), tm.toMilliSecondsDouble() / repetitions);
- ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)buf);
-
- //
- // Run the message pump.
- //
- MSG Msg;
- while(GetMessage(&Msg, NULL, 0, 0) > 0)
- {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
+ initData.properties = Ice::createProperties();
+
+ //
+ // Set a default value for Ping.Proxy so that the demo will
+ // run without a configuration file.
+ //
+ initData.properties->setProperty("Ping.Proxy", "ping:tcp -p 10000");
+
+ //
+ // Now, load the configuration file if present. Under WinCE we
+ // use "config.txt" since it can be edited with pocket word.
+ //
+ try
+ {
+ initData.properties->load("config.txt");
+ }
+ catch(const Ice::FileException&)
+ {
+ }
+
+ communicator = Ice::initialize(__argc, __argv, initData);
+
+ const char* proxyProperty = "Ping.Proxy";
+ string proxy = initData.properties->getProperty(proxyProperty);
+
+ PingPrx ping = PingPrx::checkedCast(communicator->stringToProxy(proxy));
+ if(!ping)
+ {
+ MessageBox(NULL, L"invalid proxy", L"Latency Client", MB_ICONEXCLAMATION | MB_OK);
+ return EXIT_FAILURE;
+ }
+
+ // Initial ping to setup the connection.
+ ping->ice_ping();
+
+ IceUtil::Time tm = IceUtil::Time::now();
+
+ const int repetitions = 10000;
+ wchar_t buf[1000];
+ wsprintf(buf, L"pinging server %d times (this may take a while)\r\n", repetitions);
+ ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)buf);
+ for(int i = 0; i < repetitions; ++i)
+ {
+ ping->ice_ping();
+ if((i % 100) == 0)
+ {
+ ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)L".");
+ //
+ // Run the message pump just in case the user tries to close the app.
+ //
+ MSG Msg;
+ while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&Msg);
+ DispatchMessage(&Msg);
+ }
+ if(wmDestroy)
+ {
+ break;
+ }
+ }
+ }
+
+ tm = IceUtil::Time::now() - tm;
+
+ wsprintf(buf, L"\r\ntime for %d pings: %fms\r\ntime per ping: %fms\r\n",
+ repetitions, tm.toMilliSecondsDouble(), tm.toMilliSecondsDouble() / repetitions);
+ ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)buf);
+
+ //
+ // Run the message pump.
+ //
+ MSG Msg;
+ while(GetMessage(&Msg, NULL, 0, 0) > 0)
+ {
+ TranslateMessage(&Msg);
+ DispatchMessage(&Msg);
+ }
}
catch(const Ice::Exception& ex)
{
- TCHAR wtext[1024];
- string err = ex.toString();
- mbstowcs(wtext, err.c_str(), err.size());
- MessageBox(NULL, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
+ TCHAR wtext[1024];
+ string err = ex.toString();
+ mbstowcs(wtext, err.c_str(), err.size());
+ MessageBox(NULL, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- TCHAR wtext[1024];
- string err = ex.toString();
- mbstowcs(wtext, err.c_str(), err.size());
- MessageBox(NULL, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
-
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ TCHAR wtext[1024];
+ string err = ex.toString();
+ mbstowcs(wtext, err.c_str(), err.size());
+ MessageBox(NULL, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
+
+ status = EXIT_FAILURE;
+ }
}
return status;
diff --git a/cppe/demo/IceE/latency/WinCEServer.cpp b/cppe/demo/IceE/latency/WinCEServer.cpp
index 4e40dcb27ef..3b9b27ddc9c 100644
--- a/cppe/demo/IceE/latency/WinCEServer.cpp
+++ b/cppe/demo/IceE/latency/WinCEServer.cpp
@@ -13,12 +13,6 @@
using namespace std;
using namespace Demo;
-class PingI : public Ping
-{
-public:
- // no methods.
-};
-
static HWND editHwnd;
static LRESULT CALLBACK
@@ -28,34 +22,34 @@ WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
case WM_CREATE:
{
- RECT rcClient;
- GetClientRect(hWnd, &rcClient);
- editHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"",
- WS_CHILD | WS_VISIBLE | WS_VSCROLL /*| WS_HSCROLL*/ | ES_MULTILINE,
- 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
- hWnd, (HMENU)101, GetModuleHandle(NULL), NULL);
- assert(editHwnd != NULL);
+ RECT rcClient;
+ GetClientRect(hWnd, &rcClient);
+ editHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"",
+ WS_CHILD | WS_VISIBLE | WS_VSCROLL /*| WS_HSCROLL*/ | ES_MULTILINE,
+ 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
+ hWnd, (HMENU)101, GetModuleHandle(NULL), NULL);
+ assert(editHwnd != NULL);
}
break;
case WM_SIZE:
{
- RECT rcClient;
- GetClientRect(hWnd, &rcClient);
- SetWindowPos(editHwnd, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
+ RECT rcClient;
+ GetClientRect(hWnd, &rcClient);
+ SetWindowPos(editHwnd, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
}
break;
case WM_CLOSE:
- DestroyWindow(hWnd);
- break;
+ DestroyWindow(hWnd);
+ break;
case WM_DESTROY:
- PostQuitMessage(0);
- break;
+ PostQuitMessage(0);
+ break;
default:
- return DefWindowProc(hWnd, msg, wParam, lParam);
+ return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
@@ -66,22 +60,22 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
static const TCHAR windowClassName[] = L"Latency Server";
WNDCLASS wc;
- wc.style = CS_HREDRAW|CS_VREDRAW;
- wc.lpfnWndProc = (WNDPROC)WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(NULL, 0);
- wc.hCursor = 0;
- wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.style = CS_HREDRAW|CS_VREDRAW;
+ wc.lpfnWndProc = (WNDPROC)WndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIcon(NULL, 0);
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = windowClassName;
if(!RegisterClass(&wc))
{
- MessageBox(NULL, L"Window Registration Failed!", L"Error!",
- MB_ICONEXCLAMATION | MB_OK);
- return 0;
+ MessageBox(NULL, L"Window Registration Failed!", L"Error!",
+ MB_ICONEXCLAMATION | MB_OK);
+ return 0;
}
RECT rect;
@@ -89,20 +83,20 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
int width = rect.right - rect.left;
if(width > 320)
{
- width = 320;
+ width = 320;
}
int height = rect.bottom - rect.top;
if(height > 200)
{
- height = 200;
+ height = 200;
}
HWND mainWnd = CreateWindow(windowClassName, L"Latency Server", WS_VISIBLE|WS_OVERLAPPED|WS_SYSMENU|WS_SIZEBOX,
- CW_USEDEFAULT, CW_USEDEFAULT, width, height,
- NULL, NULL, hInstance, NULL);
+ CW_USEDEFAULT, CW_USEDEFAULT, width, height,
+ NULL, NULL, hInstance, NULL);
if(mainWnd == NULL)
{
- MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
- return 0;
+ MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
+ return 0;
}
ShowWindow(mainWnd, SW_SHOW);
@@ -118,72 +112,73 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
try
{
Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
- //
- // Set a default value for Latency.Endpoints so that the demo
- // will run without a configuration file.
- //
- initData.properties->setProperty("Latency.Endpoints","tcp -p 10000");
-
- //
- // Now, load the configuration file if present. Under WinCE we
- // use "config.txt" since it can be edited with pocket word.
- //
- try
- {
- initData.properties->load("config.txt");
- }
- catch(const Ice::FileException&)
- {
- }
-
- communicator = Ice::initialize(__argc, __argv, initData);
-
- Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Latency");
- adapter->add(new PingI, communicator->stringToIdentity("ping"));
- adapter->activate();
-
- //
- // Display a helpful message to the user.
- //
- ::SendMessage(editHwnd, EM_REPLACESEL,
- (WPARAM)FALSE, (LPARAM)L"Close the window to terminate the server.\r\n");
-
- //
- // Run the message pump.
- //
- MSG Msg;
- while(GetMessage(&Msg, NULL, 0, 0) > 0)
- {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
+ initData.properties = Ice::createProperties();
+ //
+ // Set a default value for Latency.Endpoints so that the demo
+ // will run without a configuration file.
+ //
+ initData.properties->setProperty("Latency.Endpoints", "tcp -p 10000");
+
+ //
+ // Now, load the configuration file if present. Under WinCE we
+ // use "config.txt" since it can be edited with pocket word.
+ //
+ try
+ {
+ initData.properties->load("config.txt");
+ }
+ catch(const Ice::FileException&)
+ {
+ }
+
+ communicator = Ice::initialize(__argc, __argv, initData);
+
+ Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Latency");
+ Ice::ObjectPtr object = new Ping;
+ adapter->add(object, communicator->stringToIdentity("ping"));
+ adapter->activate();
+
+ //
+ // Display a helpful message to the user.
+ //
+ ::SendMessage(editHwnd, EM_REPLACESEL,
+ (WPARAM)FALSE, (LPARAM)L"Close the window to terminate the server.\r\n");
+
+ //
+ // Run the message pump.
+ //
+ MSG Msg;
+ while(GetMessage(&Msg, NULL, 0, 0) > 0)
+ {
+ TranslateMessage(&Msg);
+ DispatchMessage(&Msg);
+ }
}
catch(const Ice::Exception& ex)
{
- TCHAR wtext[1024];
- string err = ex.toString();
- mbstowcs(wtext, err.c_str(), err.size());
- MessageBox(mainWnd, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
+ TCHAR wtext[1024];
+ string err = ex.toString();
+ mbstowcs(wtext, err.c_str(), err.size());
+ MessageBox(mainWnd, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- TCHAR wtext[1024];
- string err = ex.toString();
- mbstowcs(wtext, err.c_str(), err.size());
- MessageBox(mainWnd, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
-
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ TCHAR wtext[1024];
+ string err = ex.toString();
+ mbstowcs(wtext, err.c_str(), err.size());
+ MessageBox(mainWnd, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
+
+ status = EXIT_FAILURE;
+ }
}
return status;
}
diff --git a/cppe/demo/IceE/latency/config b/cppe/demo/IceE/latency/config
deleted file mode 100644
index cb4786fad59..00000000000
--- a/cppe/demo/IceE/latency/config
+++ /dev/null
@@ -1,7 +0,0 @@
-Latency.Proxy=ping:default -p 10000 -h 127.0.0.1
-Latency.Endpoints=default -p 10000 -h 127.0.0.1
-
-#
-# Use faster blocking client side model by default.
-#
-Ice.Blocking=1
diff --git a/cppe/demo/IceE/latency/config.client b/cppe/demo/IceE/latency/config.client
new file mode 100644
index 00000000000..efede8629e4
--- /dev/null
+++ b/cppe/demo/IceE/latency/config.client
@@ -0,0 +1,5 @@
+#
+# The client reads this property to create the reference to the "Ping"
+# object in the server.
+#
+Ping.Proxy=ping:default -p 10000 -h 127.0.0.1
diff --git a/cppe/demo/IceE/latency/config.server b/cppe/demo/IceE/latency/config.server
new file mode 100644
index 00000000000..75e3479d6fe
--- /dev/null
+++ b/cppe/demo/IceE/latency/config.server
@@ -0,0 +1,10 @@
+#
+# The server creates one single object adapter with the name
+# "Latency". The following line sets the endpoints for this adapter.
+#
+Latency.Endpoints=default -p 10000 -h 127.0.0.1
+
+#
+# Warn about connection exceptions
+#
+Ice.Warn.Connections=1
diff --git a/cppe/demo/IceE/minimal/Client.cpp b/cppe/demo/IceE/minimal/Client.cpp
index a44b0ffeb55..4ab546b0d36 100644
--- a/cppe/demo/IceE/minimal/Client.cpp
+++ b/cppe/demo/IceE/minimal/Client.cpp
@@ -13,111 +13,48 @@
using namespace std;
using namespace Demo;
-void
-menu()
-{
- printf("usage:\nh: say hello\nx: exit\n?: help\n");
-}
-
-int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
-{
- if(argc > 1)
- {
- fprintf(stderr, "%s: too many arguments\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- Ice::PropertiesPtr properties = communicator->getProperties();
- const char* proxyProperty = "Hello.Proxy";
- string proxy = properties->getProperty(proxyProperty);
- if(proxy.empty())
- {
- fprintf(stderr, "%s: property `%s' not set\n", argv[0], proxyProperty);
- return EXIT_FAILURE;
- }
-
- HelloPrx hello = HelloPrx::checkedCast(communicator->stringToProxy(proxy));
- if(!hello)
- {
-
- fprintf(stderr, "%s: invalid proxy\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- menu();
-
- char c = EOF;
- do
- {
- try
- {
- printf("==> ");
- do
- {
- c = getchar();
- }
- while(c != EOF && c == '\n');
- if(c == 'h')
- {
- hello->sayHello();
- }
- else if(c == 'x')
- {
- // Nothing to do
- }
- else if(c == '?')
- {
- menu();
- }
- else
- {
- printf("unknown command `%c'\n", c);
- menu();
- }
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- }
- }
- while(c != EOF && c != 'x');
-
- return EXIT_SUCCESS;
-}
-
int
main(int argc, char* argv[])
{
-
- int status;
+ int status = EXIT_SUCCESS;
Ice::CommunicatorPtr communicator;
try
{
- Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
- initData.properties->load("config");
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
+ communicator = Ice::initialize(argc, argv);
+ if(argc > 1)
+ {
+ fprintf(stderr, "%s: too many arguments\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+ HelloPrx hello = HelloPrx::checkedCast(communicator->stringToProxy("hello:tcp -p 10000"));
+ if(!hello)
+ {
+ fprintf(stderr, "%s: invalid proxy\n", argv[0]);
+ status = EXIT_FAILURE;
+ }
+ else
+ {
+ hello->sayHello();
+ }
}
catch(const Ice::Exception& ex)
{
fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
+ }
}
return status;
diff --git a/cppe/demo/IceE/minimal/Server.cpp b/cppe/demo/IceE/minimal/Server.cpp
index be0e478fd19..efd5afe33de 100644
--- a/cppe/demo/IceE/minimal/Server.cpp
+++ b/cppe/demo/IceE/minimal/Server.cpp
@@ -20,59 +20,47 @@ public:
virtual void
sayHello(const Ice::Current&) const
{
- printf("Hello World!\n");
+ printf("Hello World!\n");
}
};
int
-run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
-{
- if(argc > 1)
- {
- fprintf(stderr, "%s: too many arguments\n", argv[0]);
- return EXIT_FAILURE;
- }
-
- Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Hello");
- Ice::ObjectPtr object = new HelloI;
- adapter->add(object, communicator->stringToIdentity("hello"));
- adapter->activate();
- communicator->waitForShutdown();
-
- return EXIT_SUCCESS;
-}
-
-int
main(int argc, char* argv[])
{
- int status;
+ int status = EXIT_SUCCESS;
Ice::CommunicatorPtr communicator;
try
{
- Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
- initData.properties->load("config");
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
+ communicator = Ice::initialize(argc, argv);
+ if(argc > 1)
+ {
+ fprintf(stderr, "%s: too many arguments\n", argv[0]);
+ return EXIT_FAILURE;
+ }
+ Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapterWithEndpoints("Hello", "tcp -p 10000");
+ Demo::HelloPtr object = new HelloI;
+ adapter->add(object, communicator->stringToIdentity("hello"));
+ adapter->activate();
+ communicator->waitForShutdown();
}
catch(const Ice::Exception& ex)
{
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
+ }
}
return status;
diff --git a/cppe/demo/IceE/minimal/WinCEClient.cpp b/cppe/demo/IceE/minimal/WinCEClient.cpp
index b53c29c6f36..8d88664baf2 100644
--- a/cppe/demo/IceE/minimal/WinCEClient.cpp
+++ b/cppe/demo/IceE/minimal/WinCEClient.cpp
@@ -25,64 +25,64 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
try
{
Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
+ initData.properties = Ice::createProperties();
- //
- // Set a default value for "Hello.Proxy" so that the demo will
- // run without a configuration file.
- //
- initData.properties->setProperty("Hello.Proxy", "hello:tcp -p 10000");
+ //
+ // Set a default value for "Hello.Proxy" so that the demo will
+ // run without a configuration file.
+ //
+ initData.properties->setProperty("Hello.Proxy", "hello:tcp -p 10000");
- //
- // Now, load the configuration file if present. Under WinCE we
- // use "config.txt" since it can be edited with pocket word.
- //
- try
- {
- initData.properties->load("config.txt");
- }
- catch(const Ice::FileException&)
- {
- }
+ //
+ // Now, load the configuration file if present. Under WinCE we
+ // use "config.txt" since it can be edited with pocket word.
+ //
+ try
+ {
+ initData.properties->load("config.txt");
+ }
+ catch(const Ice::FileException&)
+ {
+ }
- communicator = Ice::initialize(__argc, __argv, initData);
+ communicator = Ice::initialize(__argc, __argv, initData);
- HelloPrx hello =
- HelloPrx::checkedCast(communicator->stringToProxy(initData.properties->getProperty("Hello.Proxy")));
- if(!hello)
- {
- MessageBox(NULL, L"invalid proxy", L"Minimal Client", MB_ICONEXCLAMATION | MB_OK);
- return EXIT_FAILURE;
- }
+ HelloPrx hello =
+ HelloPrx::checkedCast(communicator->stringToProxy(initData.properties->getProperty("Hello.Proxy")));
+ if(!hello)
+ {
+ MessageBox(NULL, L"invalid proxy", L"Minimal Client", MB_ICONEXCLAMATION | MB_OK);
+ return EXIT_FAILURE;
+ }
- hello->sayHello();
- MessageBox(NULL, L"Sent \"sayHello()\" message", L"Minimal Client", MB_ICONEXCLAMATION | MB_OK);
+ hello->sayHello();
+ MessageBox(NULL, L"Sent \"sayHello()\" message", L"Minimal Client", MB_ICONEXCLAMATION | MB_OK);
}
catch(const Ice::Exception& ex)
{
- TCHAR wtext[1024];
- string err = ex.toString();
- mbstowcs(wtext, err.c_str(), err.size());
- MessageBox(NULL, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
+ TCHAR wtext[1024];
+ string err = ex.toString();
+ mbstowcs(wtext, err.c_str(), err.size());
+ MessageBox(NULL, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- TCHAR wtext[1024];
- string err = ex.toString();
- mbstowcs(wtext, err.c_str(), err.size());
- MessageBox(NULL, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ TCHAR wtext[1024];
+ string err = ex.toString();
+ mbstowcs(wtext, err.c_str(), err.size());
+ MessageBox(NULL, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
- status = EXIT_FAILURE;
- }
+ status = EXIT_FAILURE;
+ }
}
return status;
diff --git a/cppe/demo/IceE/minimal/WinCEServer.cpp b/cppe/demo/IceE/minimal/WinCEServer.cpp
index 8228e59aecf..970e02c3b4b 100644
--- a/cppe/demo/IceE/minimal/WinCEServer.cpp
+++ b/cppe/demo/IceE/minimal/WinCEServer.cpp
@@ -18,21 +18,21 @@ class HelloI : public Hello
public:
HelloI(HWND wnd)
- : _wnd(wnd)
+ : _wnd(wnd)
{
}
virtual void
sayHello(const Ice::Current&) const
{
- //
- // Its not legal to write to windows controls in a thread
- // other than main, so we post a custom message to the main
- // thread which will cause the message to be written to the
- // edit control.
- //
- static wchar_t* hello = L"Hello World\r\n";
- ::PostMessage(_wnd, WM_USER, (WPARAM)FALSE, (LPARAM)_wcsdup(hello));
+ //
+ // Its not legal to write to windows controls in a thread
+ // other than main, so we post a custom message to the main
+ // thread which will cause the message to be written to the
+ // edit control.
+ //
+ static wchar_t* hello = L"Hello World\r\n";
+ ::PostMessage(_wnd, WM_USER, (WPARAM)FALSE, (LPARAM)_wcsdup(hello));
}
private:
@@ -49,42 +49,42 @@ WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
case WM_USER:
{
- // tprint from a thread other than main. lParam holds a pointer to the text.
- ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)wParam, (LPARAM)lParam);
- free((wchar_t*)lParam);
+ // tprint from a thread other than main. lParam holds a pointer to the text.
+ ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)wParam, (LPARAM)lParam);
+ free((wchar_t*)lParam);
}
break;
case WM_CREATE:
{
- RECT rcClient;
- GetClientRect(hWnd, &rcClient);
- editHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"",
- WS_CHILD | WS_VISIBLE | WS_VSCROLL /*| WS_HSCROLL*/ | ES_MULTILINE,
- 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
- hWnd, (HMENU)101, GetModuleHandle(NULL), NULL);
- assert(editHwnd != NULL);
+ RECT rcClient;
+ GetClientRect(hWnd, &rcClient);
+ editHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"",
+ WS_CHILD | WS_VISIBLE | WS_VSCROLL /*| WS_HSCROLL*/ | ES_MULTILINE,
+ 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
+ hWnd, (HMENU)101, GetModuleHandle(NULL), NULL);
+ assert(editHwnd != NULL);
}
break;
case WM_SIZE:
{
- RECT rcClient;
- GetClientRect(hWnd, &rcClient);
- SetWindowPos(editHwnd, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
+ RECT rcClient;
+ GetClientRect(hWnd, &rcClient);
+ SetWindowPos(editHwnd, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
}
break;
case WM_CLOSE:
- DestroyWindow(hWnd);
- break;
+ DestroyWindow(hWnd);
+ break;
case WM_DESTROY:
- PostQuitMessage(0);
- break;
+ PostQuitMessage(0);
+ break;
default:
- return DefWindowProc(hWnd, msg, wParam, lParam);
+ return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
@@ -95,22 +95,22 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
static const TCHAR windowClassName[] = L"Minimal Server";
WNDCLASS wc;
- wc.style = CS_HREDRAW|CS_VREDRAW;
- wc.lpfnWndProc = (WNDPROC)WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(NULL, 0);
- wc.hCursor = 0;
- wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.style = CS_HREDRAW|CS_VREDRAW;
+ wc.lpfnWndProc = (WNDPROC)WndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIcon(NULL, 0);
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = windowClassName;
if(!RegisterClass(&wc))
{
- MessageBox(NULL, L"Window Registration Failed!", L"Error!",
- MB_ICONEXCLAMATION | MB_OK);
- return 0;
+ MessageBox(NULL, L"Window Registration Failed!", L"Error!",
+ MB_ICONEXCLAMATION | MB_OK);
+ return 0;
}
RECT rect;
@@ -118,20 +118,20 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
int width = rect.right - rect.left;
if(width > 320)
{
- width = 320;
+ width = 320;
}
int height = rect.bottom - rect.top;
if(height > 200)
{
- height = 200;
+ height = 200;
}
HWND mainWnd = CreateWindow(windowClassName, L"Minimal Server", WS_VISIBLE|WS_OVERLAPPED|WS_SYSMENU|WS_SIZEBOX,
- CW_USEDEFAULT, CW_USEDEFAULT, width, height,
- NULL, NULL, hInstance, NULL);
+ CW_USEDEFAULT, CW_USEDEFAULT, width, height,
+ NULL, NULL, hInstance, NULL);
if(mainWnd == NULL)
{
- MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
- return 0;
+ MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
+ return 0;
}
ShowWindow(mainWnd, SW_SHOW);
@@ -147,72 +147,73 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
try
{
Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
- //
- // Set a default value for Hello.Endpoints so that the demo
- // will run without a configuration file.
- //
- initData.properties->setProperty("Hello.Endpoints","tcp -p 10000");
-
- //
- // Now, load the configuration file if present. Under WinCE we
- // use "config.txt" since it can be edited with pocket word.
- //
- try
- {
- initData.properties->load("config.txt");
- }
- catch(const Ice::FileException&)
- {
- }
-
- communicator = Ice::initialize(__argc, __argv, initData);
-
- Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Hello");
- adapter->add(new HelloI(mainWnd), communicator->stringToIdentity("hello"));
- adapter->activate();
-
- //
- // Display a helpful message to the user.
- //
- ::SendMessage(editHwnd, EM_REPLACESEL,
- (WPARAM)FALSE, (LPARAM)L"Close the window to terminate the server.\r\n");
-
- //
- // Run the message pump.
- //
- MSG Msg;
- while(GetMessage(&Msg, NULL, 0, 0) > 0)
- {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
+ initData.properties = Ice::createProperties();
+ //
+ // Set a default value for Hello.Endpoints so that the demo
+ // will run without a configuration file.
+ //
+ initData.properties->setProperty("Hello.Endpoints","tcp -p 10000");
+
+ //
+ // Now, load the configuration file if present. Under WinCE we
+ // use "config.txt" since it can be edited with pocket word.
+ //
+ try
+ {
+ initData.properties->load("config.txt");
+ }
+ catch(const Ice::FileException&)
+ {
+ }
+
+ communicator = Ice::initialize(__argc, __argv, initData);
+
+ Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Hello");
+ HelloPtr hello = new HelloI(mainWnd);
+ adapter->add(hello, communicator->stringToIdentity("hello"));
+ adapter->activate();
+
+ //
+ // Display a helpful message to the user.
+ //
+ ::SendMessage(editHwnd, EM_REPLACESEL,
+ (WPARAM)FALSE, (LPARAM)L"Close the window to terminate the server.\r\n");
+
+ //
+ // Run the message pump.
+ //
+ MSG Msg;
+ while(GetMessage(&Msg, NULL, 0, 0) > 0)
+ {
+ TranslateMessage(&Msg);
+ DispatchMessage(&Msg);
+ }
}
catch(const Ice::Exception& ex)
{
- TCHAR wtext[1024];
- string err = ex.toString();
- mbstowcs(wtext, err.c_str(), err.size());
- MessageBox(mainWnd, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
+ TCHAR wtext[1024];
+ string err = ex.toString();
+ mbstowcs(wtext, err.c_str(), err.size());
+ MessageBox(mainWnd, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- TCHAR wtext[1024];
- string err = ex.toString();
- mbstowcs(wtext, err.c_str(), err.size());
- MessageBox(mainWnd, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
-
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ TCHAR wtext[1024];
+ string err = ex.toString();
+ mbstowcs(wtext, err.c_str(), err.size());
+ MessageBox(mainWnd, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
+
+ status = EXIT_FAILURE;
+ }
}
return status;
}
diff --git a/cppe/demo/IceE/throughput/Client.cpp b/cppe/demo/IceE/throughput/Client.cpp
index 00f2b168708..953a3f0dd2f 100644
--- a/cppe/demo/IceE/throughput/Client.cpp
+++ b/cppe/demo/IceE/throughput/Client.cpp
@@ -57,17 +57,18 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
std::string proxy = properties->getProperty(proxyProperty);
if(proxy.empty())
{
- fprintf(stderr, "%s: property `%s' not set\n", argv[0], proxyProperty);
- return EXIT_FAILURE;
+ fprintf(stderr, "%s: property `%s' not set\n", argv[0], proxyProperty);
+ return EXIT_FAILURE;
}
Ice::ObjectPrx base = communicator->stringToProxy(proxy);
ThroughputPrx throughput = ThroughputPrx::checkedCast(base);
if(!throughput)
{
- fprintf(stderr, "%s: invalid proxy\n", argv[0]);
- return EXIT_FAILURE;
+ fprintf(stderr, "%s: invalid proxy\n", argv[0]);
+ return EXIT_FAILURE;
}
+
ThroughputPrx throughputOneway = ThroughputPrx::uncheckedCast(throughput->ice_oneway());
ByteSeq byteSeq(ByteSeqSize / reduce, 0);
@@ -81,7 +82,7 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
for(i = 0; i < StringDoubleSeqSize / reduce; ++i)
{
structSeq[i].s = "hello";
- structSeq[i].d = 3.14;
+ structSeq[i].d = 3.14;
}
FixedSeq fixedSeq(FixedSeqSize / reduce);
@@ -92,9 +93,61 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
fixedSeq[i].d = 0;
}
- menu();
+ //
+ // To allow cross-language tests we may need to "warm up" the
+ // server. The warm up is to ensure that any JIT compiler will
+ // have converted any hotspots to native code. This ensures an
+ // accurate throughput measurement.
+ //
+ if(throughput->needsWarmup())
+ {
+ throughput->startWarmup();
+
+ ByteSeq emptyBytesBuf(1);
+ emptyBytesBuf.resize(1);
+ pair<const Ice::Byte*, const Ice::Byte*> emptyBytes;
+ emptyBytes.first = &emptyBytesBuf[0];
+ emptyBytes.second = emptyBytes.first + emptyBytesBuf.size();
+
+ StringSeq emptyStrings(1);
+ emptyStrings.resize(1);
+
+ StringDoubleSeq emptyStructs(1);
+ emptyStructs.resize(1);
+
+ FixedSeq emptyFixed(1);
+ emptyFixed.resize(1);
+
+ printf("warming up the server...");
+ fflush(stdout);
+ for(int i = 0; i < 10000; i++)
+ {
+ throughput->sendByteSeq(emptyBytes);
+ throughput->sendStringSeq(emptyStrings);
+ throughput->sendStructSeq(emptyStructs);
+ throughput->sendFixedSeq(emptyFixed);
+
+ throughput->recvByteSeq();
+ throughput->recvStringSeq();
+ throughput->recvStructSeq();
+ throughput->recvFixedSeq();
+
+ throughput->echoByteSeq(emptyBytesBuf);
+ throughput->echoStringSeq(emptyStrings);
+ throughput->echoStructSeq(emptyStructs);
+ throughput->echoFixedSeq(emptyFixed);
+ }
+
+ throughput->endWarmup();
- throughput->ice_ping(); // Initial ping to setup the connection.
+ printf(" ok\n");
+ }
+ else
+ {
+ throughput->ice_ping(); // Initial ping to setup the connection.
+ }
+
+ menu();
//
// By default use byte sequence.
@@ -105,300 +158,300 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
char c = EOF;
do
{
- try
- {
- printf("==> ");
- do
- {
- c = getchar();
- }
- while(c != EOF && c == '\n');
-
- IceUtil::Time tm = IceUtil::Time::now();
- const int repetitions = 1000;
-
- if(c == '1' || c == '2' || c == '3' || c == '4')
- {
- currentType = c;
- switch(c)
- {
- case '1':
- {
- printf("using byte sequences\n");
- seqSize = ByteSeqSize / reduce;
- break;
- }
-
- case '2':
- {
- printf("using string sequences\n");
- seqSize = StringSeqSize / reduce;
- break;
- }
-
- case '3':
- {
- printf("using variable-length struct sequences\n");
- seqSize = StringDoubleSeqSize / reduce;
- break;
- }
-
- case '4':
- {
- printf("using fixed-length struct sequences\n");
- seqSize = FixedSeqSize / reduce;
- break;
- }
- }
- }
- else if(c == 't' || c == 'o' || c == 'r' || c == 'e')
- {
- switch(c)
- {
- case 't':
- case 'o':
- {
- printf("sending");
- break;
- }
-
- case 'r':
- {
- printf("receiving");
- break;
- }
-
- case 'e':
- {
- printf("sending and receiving");
- break;
- }
- }
-
- printf(" %d", repetitions);
- switch(currentType)
- {
- case '1':
- {
- printf(" byte");
- break;
- }
-
- case '2':
- {
- printf(" string");
- break;
- }
-
- case '3':
- {
- printf(" variable-length struct");
- break;
- }
-
- case '4':
- {
- printf(" fixed-length struct");
- break;
- }
- }
- printf(" sequences of size %d", seqSize);
-
-
- if(c == 'o')
- {
- printf(" as oneway");
- }
-
- printf("...\n");
-
- for(int i = 0; i < repetitions; ++i)
- {
- switch(currentType)
- {
- case '1':
- {
- switch(c)
- {
- case 't':
- {
- throughput->sendByteSeq(byteArr);
- break;
- }
-
- case 'o':
- {
- throughputOneway->sendByteSeq(byteArr);
- break;
- }
-
- case 'r':
- {
- throughput->recvByteSeq();
- break;
- }
-
- case 'e':
- {
- throughput->echoByteSeq(byteSeq);
- break;
- }
- }
- break;
- }
-
- case '2':
- {
- switch(c)
- {
- case 't':
- {
- throughput->sendStringSeq(stringSeq);
- break;
- }
-
- case 'o':
- {
- throughputOneway->sendStringSeq(stringSeq);
- break;
- }
-
- case 'r':
- {
- throughput->recvStringSeq();
- break;
- }
-
- case 'e':
- {
- throughput->echoStringSeq(stringSeq);
- break;
- }
- }
- break;
- }
-
- case '3':
- {
- switch(c)
- {
- case 't':
- {
- throughput->sendStructSeq(structSeq);
- break;
- }
-
- case 'o':
- {
- throughputOneway->sendStructSeq(structSeq);
- break;
- }
-
- case 'r':
- {
- throughput->recvStructSeq();
- break;
- }
-
- case 'e':
- {
- throughput->echoStructSeq(structSeq);
- break;
- }
- }
- break;
- }
-
- case '4':
- {
- switch(c)
- {
- case 't':
- {
- throughput->sendFixedSeq(fixedSeq);
- break;
- }
-
- case 'o':
- {
- throughputOneway->sendFixedSeq(fixedSeq);
- break;
- }
-
- case 'r':
- {
- throughput->recvFixedSeq();
- break;
- }
-
- case 'e':
- {
- throughput->echoFixedSeq(fixedSeq);
- break;
- }
- }
- break;
- }
- }
- }
-
- tm = IceUtil::Time::now() - tm;
- printf("time for %d sequences: %lfms\n", repetitions, tm.toMilliSecondsDouble());
- printf("time per sequence: %lfms\n", tm.toMilliSecondsDouble() / repetitions);
- int wireSize = 0;
- switch(currentType)
- {
- case '1':
- {
- wireSize = 1;
- break;
- }
- case '2':
- {
- wireSize = static_cast<int>(stringSeq[0].size());
- break;
- }
- case '3':
- {
- wireSize = static_cast<int>(structSeq[0].s.size());
- wireSize += 8; // Size of double on the wire.
- break;
- }
- case '4':
- {
- wireSize = 16; // Size of two ints and a double on the wire.
- break;
- }
- }
- double mbit = repetitions * seqSize * wireSize * 8.0 / tm.toMicroSeconds();
- if(c == 'e')
- {
- mbit *= 2;
- }
- printf("throughput: %.2lfMbps\n", mbit);
- }
- else if(c == 's')
- {
- throughput->shutdown();
- }
- else if(c == 'x')
- {
- // Nothing to do
- }
- else if(c == '?')
- {
- menu();
- }
- else
- {
- printf("unknown command `%c'\n", c);
- menu();
- }
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- }
+ try
+ {
+ printf("==> ");
+ do
+ {
+ c = getchar();
+ }
+ while(c != EOF && c == '\n');
+
+ IceUtil::Time tm = IceUtil::Time::now();
+ const int repetitions = 1000;
+
+ if(c == '1' || c == '2' || c == '3' || c == '4')
+ {
+ currentType = c;
+ switch(c)
+ {
+ case '1':
+ {
+ printf("using byte sequences\n");
+ seqSize = ByteSeqSize / reduce;
+ break;
+ }
+
+ case '2':
+ {
+ printf("using string sequences\n");
+ seqSize = StringSeqSize / reduce;
+ break;
+ }
+
+ case '3':
+ {
+ printf("using variable-length struct sequences\n");
+ seqSize = StringDoubleSeqSize / reduce;
+ break;
+ }
+
+ case '4':
+ {
+ printf("using fixed-length struct sequences\n");
+ seqSize = FixedSeqSize / reduce;
+ break;
+ }
+ }
+ }
+ else if(c == 't' || c == 'o' || c == 'r' || c == 'e')
+ {
+ switch(c)
+ {
+ case 't':
+ case 'o':
+ {
+ printf("sending");
+ break;
+ }
+
+ case 'r':
+ {
+ printf("receiving");
+ break;
+ }
+
+ case 'e':
+ {
+ printf("sending and receiving");
+ break;
+ }
+ }
+
+ printf(" %d", repetitions);
+ switch(currentType)
+ {
+ case '1':
+ {
+ printf(" byte");
+ break;
+ }
+
+ case '2':
+ {
+ printf(" string");
+ break;
+ }
+
+ case '3':
+ {
+ printf(" variable-length struct");
+ break;
+ }
+
+ case '4':
+ {
+ printf(" fixed-length struct");
+ break;
+ }
+ }
+ printf(" sequences of size %d", seqSize);
+
+
+ if(c == 'o')
+ {
+ printf(" as oneway");
+ }
+
+ printf("...\n");
+
+ for(int i = 0; i < repetitions; ++i)
+ {
+ switch(currentType)
+ {
+ case '1':
+ {
+ switch(c)
+ {
+ case 't':
+ {
+ throughput->sendByteSeq(byteArr);
+ break;
+ }
+
+ case 'o':
+ {
+ throughputOneway->sendByteSeq(byteArr);
+ break;
+ }
+
+ case 'r':
+ {
+ throughput->recvByteSeq();
+ break;
+ }
+
+ case 'e':
+ {
+ throughput->echoByteSeq(byteSeq);
+ break;
+ }
+ }
+ break;
+ }
+
+ case '2':
+ {
+ switch(c)
+ {
+ case 't':
+ {
+ throughput->sendStringSeq(stringSeq);
+ break;
+ }
+
+ case 'o':
+ {
+ throughputOneway->sendStringSeq(stringSeq);
+ break;
+ }
+
+ case 'r':
+ {
+ throughput->recvStringSeq();
+ break;
+ }
+
+ case 'e':
+ {
+ throughput->echoStringSeq(stringSeq);
+ break;
+ }
+ }
+ break;
+ }
+
+ case '3':
+ {
+ switch(c)
+ {
+ case 't':
+ {
+ throughput->sendStructSeq(structSeq);
+ break;
+ }
+
+ case 'o':
+ {
+ throughputOneway->sendStructSeq(structSeq);
+ break;
+ }
+
+ case 'r':
+ {
+ throughput->recvStructSeq();
+ break;
+ }
+
+ case 'e':
+ {
+ throughput->echoStructSeq(structSeq);
+ break;
+ }
+ }
+ break;
+ }
+
+ case '4':
+ {
+ switch(c)
+ {
+ case 't':
+ {
+ throughput->sendFixedSeq(fixedSeq);
+ break;
+ }
+
+ case 'o':
+ {
+ throughputOneway->sendFixedSeq(fixedSeq);
+ break;
+ }
+
+ case 'r':
+ {
+ throughput->recvFixedSeq();
+ break;
+ }
+
+ case 'e':
+ {
+ throughput->echoFixedSeq(fixedSeq);
+ break;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ tm = IceUtil::Time::now() - tm;
+ printf("time for %d sequences: %lfms\n", repetitions, tm.toMilliSecondsDouble());
+ printf("time per sequence: %lfms\n", tm.toMilliSecondsDouble() / repetitions);
+ int wireSize = 0;
+ switch(currentType)
+ {
+ case '1':
+ {
+ wireSize = 1;
+ break;
+ }
+ case '2':
+ {
+ wireSize = static_cast<int>(stringSeq[0].size());
+ break;
+ }
+ case '3':
+ {
+ wireSize = static_cast<int>(structSeq[0].s.size());
+ wireSize += 8; // Size of double on the wire.
+ break;
+ }
+ case '4':
+ {
+ wireSize = 16; // Size of two ints and a double on the wire.
+ break;
+ }
+ }
+ double mbit = repetitions * seqSize * wireSize * 8.0 / tm.toMicroSeconds();
+ if(c == 'e')
+ {
+ mbit *= 2;
+ }
+ printf("throughput: %.2lfMbps\n", mbit);
+ }
+ else if(c == 's')
+ {
+ throughput->shutdown();
+ }
+ else if(c == 'x')
+ {
+ // Nothing to do
+ }
+ else if(c == '?')
+ {
+ menu();
+ }
+ else
+ {
+ printf("unknown command `%c'\n", c);
+ menu();
+ }
+ }
+ catch(const Ice::Exception& ex)
+ {
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ }
}
while(c != EOF && c != 'x');
@@ -414,28 +467,28 @@ main(int argc, char* argv[])
try
{
Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
- initData.properties->load("config");
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
+ initData.properties = Ice::createProperties();
+ initData.properties->load("config.client");
+ communicator = Ice::initialize(argc, argv, initData);
+ status = run(argc, argv, communicator);
}
catch(const Ice::Exception& ex)
{
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
+ }
}
return status;
diff --git a/cppe/demo/IceE/throughput/Server.cpp b/cppe/demo/IceE/throughput/Server.cpp
index 2c22baf53b0..99790cc758b 100644
--- a/cppe/demo/IceE/throughput/Server.cpp
+++ b/cppe/demo/IceE/throughput/Server.cpp
@@ -22,14 +22,14 @@ run(int argc, char* argv[], const Ice::CommunicatorPtr& communicator)
for(int i = 0; i < argc; ++i)
{
if(strcmp(argv[i], "--small") == 0)
- {
- reduce = 100;
- }
+ {
+ reduce = 100;
+ }
}
Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Throughput");
- Ice::ObjectPtr object = new ThroughputI(reduce);
- adapter->add(object, communicator->stringToIdentity("throughput"));
+ Demo::ThroughputPtr servant = new ThroughputI(reduce);
+ adapter->add(servant, communicator->stringToIdentity("throughput"));
adapter->activate();
communicator->waitForShutdown();
return EXIT_SUCCESS;
@@ -44,29 +44,29 @@ main(int argc, char* argv[])
try
{
Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
- initData.properties->load("config");
- initData.properties->setProperty("Ice.Override.Timeout", "100");
- communicator = Ice::initialize(argc, argv, initData);
- status = run(argc, argv, communicator);
+ initData.properties = Ice::createProperties();
+ initData.properties->load("config.server");
+ initData.properties->setProperty("Ice.Override.Timeout", "100");
+ communicator = Ice::initialize(argc, argv, initData);
+ status = run(argc, argv, communicator);
}
catch(const Ice::Exception& ex)
{
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- fprintf(stderr, "%s\n", ex.toString().c_str());
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ status = EXIT_FAILURE;
+ }
}
return status;
diff --git a/cppe/demo/IceE/throughput/Throughput.ice b/cppe/demo/IceE/throughput/Throughput.ice
index 180b0fcea2b..c2aabb7fd04 100644
--- a/cppe/demo/IceE/throughput/Throughput.ice
+++ b/cppe/demo/IceE/throughput/Throughput.ice
@@ -38,6 +38,10 @@ const int FixedSeqSize = 50000;
interface Throughput
{
+ bool needsWarmup();
+ void startWarmup();
+ void endWarmup();
+
void sendByteSeq(["cpp:array"] ByteSeq seq);
ByteSeq recvByteSeq();
ByteSeq echoByteSeq(ByteSeq seq);
diff --git a/cppe/demo/IceE/throughput/ThroughputI.cpp b/cppe/demo/IceE/throughput/ThroughputI.cpp
index f2e8c6ba6b5..a51a30e8a4e 100644
--- a/cppe/demo/IceE/throughput/ThroughputI.cpp
+++ b/cppe/demo/IceE/throughput/ThroughputI.cpp
@@ -17,22 +17,42 @@ ThroughputI::ThroughputI(int reduce) :
_byteSeq(ByteSeqSize / reduce, 0),
_stringSeq(StringSeqSize / reduce, "hello"),
_structSeq(StringDoubleSeqSize / reduce),
- _fixedSeq(FixedSeqSize / reduce)
+ _fixedSeq(FixedSeqSize / reduce),
+ _warmup(false)
{
int i;
for(i = 0; i < StringDoubleSeqSize / reduce; ++i)
{
- _structSeq[i].s = "hello";
- _structSeq[i].d = 3.14;
+ _structSeq[i].s = "hello";
+ _structSeq[i].d = 3.14;
}
for(i = 0; i < FixedSeqSize / reduce; ++i)
{
- _fixedSeq[i].i = 0;
- _fixedSeq[i].j = 0;
- _fixedSeq[i].d = 0;
+ _fixedSeq[i].i = 0;
+ _fixedSeq[i].j = 0;
+ _fixedSeq[i].d = 0;
}
}
+bool
+ThroughputI::needsWarmup(const Ice::Current&)
+{
+ _warmup = false;
+ return false;
+}
+
+void
+ThroughputI::startWarmup(const Ice::Current&)
+{
+ _warmup = true;
+}
+
+void
+ThroughputI::endWarmup(const Ice::Current&)
+{
+ _warmup = false;
+}
+
void
ThroughputI::sendByteSeq(const pair<const Ice::Byte*, const Ice::Byte*>&, const Ice::Current&)
{
@@ -41,7 +61,14 @@ ThroughputI::sendByteSeq(const pair<const Ice::Byte*, const Ice::Byte*>&, const
ByteSeq
ThroughputI::recvByteSeq(const Ice::Current&)
{
- return _byteSeq;
+ if(_warmup)
+ {
+ return Demo::ByteSeq();
+ }
+ else
+ {
+ return _byteSeq;
+ }
}
ByteSeq
@@ -58,7 +85,14 @@ ThroughputI::sendStringSeq(const StringSeq&, const Ice::Current&)
StringSeq
ThroughputI::recvStringSeq(const Ice::Current&)
{
- return _stringSeq;
+ if(_warmup)
+ {
+ return Demo::StringSeq();
+ }
+ else
+ {
+ return _stringSeq;
+ }
}
StringSeq
@@ -75,7 +109,14 @@ ThroughputI::sendStructSeq(const StringDoubleSeq&, const Ice::Current&)
StringDoubleSeq
ThroughputI::recvStructSeq(const Ice::Current&)
{
- return _structSeq;
+ if(_warmup)
+ {
+ return Demo::StringDoubleSeq();
+ }
+ else
+ {
+ return _structSeq;
+ }
}
StringDoubleSeq
@@ -92,7 +133,14 @@ ThroughputI::sendFixedSeq(const FixedSeq&, const Ice::Current&)
FixedSeq
ThroughputI::recvFixedSeq(const Ice::Current&)
{
- return _fixedSeq;
+ if(_warmup)
+ {
+ return Demo::FixedSeq();
+ }
+ else
+ {
+ return _fixedSeq;
+ }
}
FixedSeq
diff --git a/cppe/demo/IceE/throughput/ThroughputI.h b/cppe/demo/IceE/throughput/ThroughputI.h
index f7192387dab..40bf1adea00 100644
--- a/cppe/demo/IceE/throughput/ThroughputI.h
+++ b/cppe/demo/IceE/throughput/ThroughputI.h
@@ -18,6 +18,9 @@ public:
ThroughputI(int);
+ virtual bool needsWarmup(const Ice::Current&);
+ virtual void startWarmup(const Ice::Current&);
+ virtual void endWarmup(const Ice::Current&);
virtual void sendByteSeq(const std::pair<const Ice::Byte*, const Ice::Byte*>&, const Ice::Current&);
virtual Demo::ByteSeq recvByteSeq(const Ice::Current&);
virtual Demo::ByteSeq echoByteSeq(const Demo::ByteSeq&, const Ice::Current&);
@@ -38,6 +41,8 @@ private:
const Demo::StringSeq _stringSeq;
/*const*/ Demo::StringDoubleSeq _structSeq;
/*const*/ Demo::FixedSeq _fixedSeq;
+
+ bool _warmup;
};
#endif
diff --git a/cppe/demo/IceE/throughput/WinCEClient.cpp b/cppe/demo/IceE/throughput/WinCEClient.cpp
index dc15f3c6a4e..84ec30147d2 100644
--- a/cppe/demo/IceE/throughput/WinCEClient.cpp
+++ b/cppe/demo/IceE/throughput/WinCEClient.cpp
@@ -23,35 +23,35 @@ WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
case WM_CREATE:
{
- RECT rcClient;
- GetClientRect(hWnd, &rcClient);
- editHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"",
- WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE,
- 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
- hWnd, (HMENU)101, GetModuleHandle(NULL), NULL);
- assert(editHwnd != NULL);
+ RECT rcClient;
+ GetClientRect(hWnd, &rcClient);
+ editHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"",
+ WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE,
+ 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
+ hWnd, (HMENU)101, GetModuleHandle(NULL), NULL);
+ assert(editHwnd != NULL);
}
break;
case WM_SIZE:
{
- RECT rcClient;
- GetClientRect(hWnd, &rcClient);
- SetWindowPos(editHwnd, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
+ RECT rcClient;
+ GetClientRect(hWnd, &rcClient);
+ SetWindowPos(editHwnd, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
}
break;
case WM_CLOSE:
- DestroyWindow(hWnd);
- break;
+ DestroyWindow(hWnd);
+ break;
case WM_DESTROY:
- wmDestroy = true;
- PostQuitMessage(0);
- break;
+ wmDestroy = true;
+ PostQuitMessage(0);
+ break;
default:
- return DefWindowProc(hWnd, msg, wParam, lParam);
+ return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
@@ -62,21 +62,21 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
static const TCHAR windowClassName[] = L"Throughput Client";
WNDCLASS wc;
- wc.style = CS_HREDRAW|CS_VREDRAW;
- wc.lpfnWndProc = (WNDPROC)WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(NULL, 0);
- wc.hCursor = 0;
- wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.style = CS_HREDRAW|CS_VREDRAW;
+ wc.lpfnWndProc = (WNDPROC)WndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIcon(NULL, 0);
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = windowClassName;
if(!RegisterClass(&wc))
{
- MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
- return 0;
+ MessageBox(NULL, L"Window Registration Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
+ return 0;
}
RECT rect;
@@ -84,20 +84,20 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
int width = rect.right - rect.left;
if(width > 320)
{
- width = 320;
+ width = 320;
}
int height = rect.bottom - rect.top;
if(height > 200)
{
- height = 200;
+ height = 200;
}
HWND mainWnd = CreateWindow(windowClassName, L"Throughput Client", WS_VISIBLE|WS_OVERLAPPED|WS_SYSMENU|WS_SIZEBOX,
- CW_USEDEFAULT, CW_USEDEFAULT, width, height,
- NULL, NULL, hInstance, NULL);
+ CW_USEDEFAULT, CW_USEDEFAULT, width, height,
+ NULL, NULL, hInstance, NULL);
if(mainWnd == NULL)
{
- MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
- return 0;
+ MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
+ return 0;
}
ShowWindow(mainWnd, SW_SHOW);
@@ -108,134 +108,134 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
try
{
- Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
-
- //
- // Set a default value for Throughput.Proxy so that the demo will
- // run without a configuration file.
- //
- initData.properties->setProperty("Throughput.Proxy", "throughput:tcp -p 10000");
-
- //
- // Now, load the configuration file if present. Under WinCE we
- // use "config.txt" since it can be edited with pocket word.
- //
- try
- {
- initData.properties->load("config.txt");
- }
- catch(const Ice::FileException&)
- {
- }
-
- communicator = Ice::initialize(__argc, __argv, initData);
-
- const char* proxyProperty = "Throughput.Proxy";
- string proxy = initData.properties->getProperty(proxyProperty);
-
- ThroughputPrx throughput = ThroughputPrx::checkedCast(communicator->stringToProxy(proxy));
- if(!throughput)
- {
- MessageBox(NULL, L"invalid proxy", L"Throughput Client", MB_ICONEXCLAMATION | MB_OK);
- return EXIT_FAILURE;
- }
- ThroughputPrx throughputOneway = ThroughputPrx::uncheckedCast(throughput->ice_oneway());
+ Ice::InitializationData initData;
+ initData.properties = Ice::createProperties();
+
+ //
+ // Set a default value for Throughput.Proxy so that the demo will
+ // run without a configuration file.
+ //
+ initData.properties->setProperty("Throughput.Proxy", "throughput:tcp -p 10000");
+
+ //
+ // Now, load the configuration file if present. Under WinCE we
+ // use "config.txt" since it can be edited with pocket word.
+ //
+ try
+ {
+ initData.properties->load("config.txt");
+ }
+ catch(const Ice::FileException&)
+ {
+ }
+
+ communicator = Ice::initialize(__argc, __argv, initData);
+
+ const char* proxyProperty = "Throughput.Proxy";
+ string proxy = initData.properties->getProperty(proxyProperty);
+
+ ThroughputPrx throughput = ThroughputPrx::checkedCast(communicator->stringToProxy(proxy));
+ if(!throughput)
+ {
+ MessageBox(NULL, L"invalid proxy", L"Throughput Client", MB_ICONEXCLAMATION | MB_OK);
+ return EXIT_FAILURE;
+ }
+ ThroughputPrx throughputOneway = ThroughputPrx::uncheckedCast(throughput->ice_oneway());
//
// The amount by which we reduce buffer sizes for CE runs
//
const int reduce = 100;
- //
- // Initialize data structures
- //
- ByteSeq byteSeq(ByteSeqSize / reduce, 0);
- pair<const Ice::Byte*, const Ice::Byte*> byteArr;
- byteArr.first = &byteSeq[0];
- byteArr.second = byteArr.first + byteSeq.size();
-
- StringSeq stringSeq(StringSeqSize / reduce, "hello");
-
- StringDoubleSeq structSeq(StringDoubleSeqSize / reduce);
- int i;
- for(i = 0; i < StringDoubleSeqSize / reduce; ++i)
- {
- structSeq[i].s = "hello";
- structSeq[i].d = 3.14;
- }
-
- FixedSeq fixedSeq(FixedSeqSize / reduce);
- for(i = 0; i < FixedSeqSize / reduce; ++i)
- {
- fixedSeq[i].i = 0;
- fixedSeq[i].j = 0;
- fixedSeq[i].d = 0;
- }
-
- const int repetitions = 1000;
-
- // Initial ping to setup the connection.
- throughput->ice_ping();
-
- ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE,
- (LPARAM)L"Running throughput tests (this may take a while)\r\n");
-
- for(int type = 0; type < 4; ++type)
- {
- wchar_t* data;
- int seqSize;
- if(type == 0)
- {
- data = L"byte";
- seqSize = ByteSeqSize / reduce;
- }
- else if(type == 1)
- {
- data = L"string";
- seqSize = StringSeqSize / reduce;
- }
- else if(type == 2)
- {
- data = L"variable-length struct";
- seqSize = StringDoubleSeqSize / reduce;
- }
- else if(type == 3)
- {
- data = L"fixed-length struct";
- seqSize = FixedSeqSize / reduce;
- }
-
- for(int mode = 0; mode < 4; ++mode)
- {
- wchar_t* action;
- wchar_t* qualifier = L"";
- if(mode == 0)
- {
- action = L"sending";
- }
- else if(mode == 1)
- {
- action = L"sending";
- qualifier = L" as oneway";
- }
- else if(mode == 2)
- {
- action = L"receiving";
- }
- else if(mode == 3)
- {
- action = L"sending and receiving";
- }
-
- wchar_t buf[1000];
- wsprintf(buf, L"\r\n%s %d %s sequences of size %d%s\r\n", action, repetitions, data, seqSize,
- qualifier);
- ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)buf);
-
- IceUtil::Time tm = IceUtil::Time::now();
- for(i = 0; i < repetitions; ++i)
- {
+ //
+ // Initialize data structures
+ //
+ ByteSeq byteSeq(ByteSeqSize / reduce, 0);
+ pair<const Ice::Byte*, const Ice::Byte*> byteArr;
+ byteArr.first = &byteSeq[0];
+ byteArr.second = byteArr.first + byteSeq.size();
+
+ StringSeq stringSeq(StringSeqSize / reduce, "hello");
+
+ StringDoubleSeq structSeq(StringDoubleSeqSize / reduce);
+ int i;
+ for(i = 0; i < StringDoubleSeqSize / reduce; ++i)
+ {
+ structSeq[i].s = "hello";
+ structSeq[i].d = 3.14;
+ }
+
+ FixedSeq fixedSeq(FixedSeqSize / reduce);
+ for(i = 0; i < FixedSeqSize / reduce; ++i)
+ {
+ fixedSeq[i].i = 0;
+ fixedSeq[i].j = 0;
+ fixedSeq[i].d = 0;
+ }
+
+ const int repetitions = 1000;
+
+ // Initial ping to setup the connection.
+ throughput->ice_ping();
+
+ ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE,
+ (LPARAM)L"Running throughput tests (this may take a while)\r\n");
+
+ for(int type = 0; type < 4; ++type)
+ {
+ wchar_t* data;
+ int seqSize;
+ if(type == 0)
+ {
+ data = L"byte";
+ seqSize = ByteSeqSize / reduce;
+ }
+ else if(type == 1)
+ {
+ data = L"string";
+ seqSize = StringSeqSize / reduce;
+ }
+ else if(type == 2)
+ {
+ data = L"variable-length struct";
+ seqSize = StringDoubleSeqSize / reduce;
+ }
+ else if(type == 3)
+ {
+ data = L"fixed-length struct";
+ seqSize = FixedSeqSize / reduce;
+ }
+
+ for(int mode = 0; mode < 4; ++mode)
+ {
+ wchar_t* action;
+ wchar_t* qualifier = L"";
+ if(mode == 0)
+ {
+ action = L"sending";
+ }
+ else if(mode == 1)
+ {
+ action = L"sending";
+ qualifier = L" as oneway";
+ }
+ else if(mode == 2)
+ {
+ action = L"receiving";
+ }
+ else if(mode == 3)
+ {
+ action = L"sending and receiving";
+ }
+
+ wchar_t buf[1000];
+ wsprintf(buf, L"\r\n%s %d %s sequences of size %d%s\r\n", action, repetitions, data, seqSize,
+ qualifier);
+ ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)buf);
+
+ IceUtil::Time tm = IceUtil::Time::now();
+ for(i = 0; i < repetitions; ++i)
+ {
switch(type)
{
case 0:
@@ -361,31 +361,31 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
}
break;
}
- }
-
- if((i % 100) == 0)
- {
- ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)L".");
- //
- // Run the message pump just in case the user tries to close the app.
- //
- MSG Msg;
- while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
- {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
- if(wmDestroy)
- {
- break;
- }
- }
- }
- tm = IceUtil::Time::now() - tm;
-
- wsprintf(buf, L"\r\ntime for %d sequences: %.04fms\r\ntime per sequence: %.04fms\r\n",
- repetitions, tm.toMilliSecondsDouble(), tm.toMilliSecondsDouble() / repetitions);
- ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)buf);
+ }
+
+ if((i % 100) == 0)
+ {
+ ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)L".");
+ //
+ // Run the message pump just in case the user tries to close the app.
+ //
+ MSG Msg;
+ while(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE))
+ {
+ TranslateMessage(&Msg);
+ DispatchMessage(&Msg);
+ }
+ if(wmDestroy)
+ {
+ break;
+ }
+ }
+ }
+ tm = IceUtil::Time::now() - tm;
+
+ wsprintf(buf, L"\r\ntime for %d sequences: %.04fms\r\ntime per sequence: %.04fms\r\n",
+ repetitions, tm.toMilliSecondsDouble(), tm.toMilliSecondsDouble() / repetitions);
+ ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)buf);
int wireSize = 0;
switch(type)
@@ -417,22 +417,22 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
{
mbit *= 2;
}
- wsprintf(buf, L"throughput: %.04f MBit/s\r\n", mbit);
- ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)buf);
- }
- }
-
- ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)L"\r\nThroughput tests completed\r\n");
+ wsprintf(buf, L"throughput: %.04f MBit/s\r\n", mbit);
+ ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)buf);
+ }
+ }
+
+ ::SendMessage(editHwnd, EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)L"\r\nThroughput tests completed\r\n");
}
catch(const Ice::Exception& ex)
{
- TCHAR wtext[1024];
- string err = ex.toString();
- mbstowcs(wtext, err.c_str(), err.size());
- MessageBox(NULL, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
+ TCHAR wtext[1024];
+ string err = ex.toString();
+ mbstowcs(wtext, err.c_str(), err.size());
+ MessageBox(NULL, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
//
@@ -441,25 +441,25 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
MSG Msg;
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
+ TranslateMessage(&Msg);
+ DispatchMessage(&Msg);
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- TCHAR wtext[1024];
- string err = ex.toString();
- mbstowcs(wtext, err.c_str(), err.size());
- MessageBox(NULL, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
-
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ TCHAR wtext[1024];
+ string err = ex.toString();
+ mbstowcs(wtext, err.c_str(), err.size());
+ MessageBox(NULL, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
+
+ status = EXIT_FAILURE;
+ }
}
return status;
diff --git a/cppe/demo/IceE/throughput/WinCEServer.cpp b/cppe/demo/IceE/throughput/WinCEServer.cpp
index b80eacc7fe5..a8d8c4a5b11 100644
--- a/cppe/demo/IceE/throughput/WinCEServer.cpp
+++ b/cppe/demo/IceE/throughput/WinCEServer.cpp
@@ -22,34 +22,34 @@ WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
case WM_CREATE:
{
- RECT rcClient;
- GetClientRect(hWnd, &rcClient);
- editHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"",
- WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE,
- 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
- hWnd, (HMENU)101, GetModuleHandle(NULL), NULL);
- assert(editHwnd != NULL);
+ RECT rcClient;
+ GetClientRect(hWnd, &rcClient);
+ editHwnd = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"",
+ WS_CHILD | WS_VISIBLE | WS_VSCROLL | ES_MULTILINE,
+ 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top,
+ hWnd, (HMENU)101, GetModuleHandle(NULL), NULL);
+ assert(editHwnd != NULL);
}
break;
case WM_SIZE:
{
- RECT rcClient;
- GetClientRect(hWnd, &rcClient);
- SetWindowPos(editHwnd, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
+ RECT rcClient;
+ GetClientRect(hWnd, &rcClient);
+ SetWindowPos(editHwnd, NULL, 0, 0, rcClient.right, rcClient.bottom, SWP_NOZORDER);
}
break;
case WM_CLOSE:
- DestroyWindow(hWnd);
- break;
+ DestroyWindow(hWnd);
+ break;
case WM_DESTROY:
- PostQuitMessage(0);
- break;
+ PostQuitMessage(0);
+ break;
default:
- return DefWindowProc(hWnd, msg, wParam, lParam);
+ return DefWindowProc(hWnd, msg, wParam, lParam);
}
return 0;
}
@@ -60,22 +60,22 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
static const TCHAR windowClassName[] = L"Throughput Server";
WNDCLASS wc;
- wc.style = CS_HREDRAW|CS_VREDRAW;
- wc.lpfnWndProc = (WNDPROC)WndProc;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon(NULL, 0);
- wc.hCursor = 0;
- wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
+ wc.style = CS_HREDRAW|CS_VREDRAW;
+ wc.lpfnWndProc = (WNDPROC)WndProc;
+ wc.cbClsExtra = 0;
+ wc.cbWndExtra = 0;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIcon(NULL, 0);
+ wc.hCursor = 0;
+ wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
wc.lpszMenuName = NULL;
wc.lpszClassName = windowClassName;
if(!RegisterClass(&wc))
{
- MessageBox(NULL, L"Window Registration Failed!", L"Error!",
- MB_ICONEXCLAMATION | MB_OK);
- return 0;
+ MessageBox(NULL, L"Window Registration Failed!", L"Error!",
+ MB_ICONEXCLAMATION | MB_OK);
+ return 0;
}
RECT rect;
@@ -83,20 +83,20 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
int width = rect.right - rect.left;
if(width > 320)
{
- width = 320;
+ width = 320;
}
int height = rect.bottom - rect.top;
if(height > 200)
{
- height = 200;
+ height = 200;
}
HWND mainWnd = CreateWindow(windowClassName, L"Throughput Server", WS_VISIBLE|WS_OVERLAPPED|WS_SYSMENU|WS_SIZEBOX,
- CW_USEDEFAULT, CW_USEDEFAULT, width, height,
- NULL, NULL, hInstance, NULL);
+ CW_USEDEFAULT, CW_USEDEFAULT, width, height,
+ NULL, NULL, hInstance, NULL);
if(mainWnd == NULL)
{
- MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
- return 0;
+ MessageBox(NULL, L"Window Creation Failed!", L"Error!", MB_ICONEXCLAMATION | MB_OK);
+ return 0;
}
ShowWindow(mainWnd, SW_SHOW);
@@ -112,74 +112,74 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
try
{
Ice::InitializationData initData;
- initData.properties = Ice::createProperties();
-
- //
- // Set a default value for Latency.Endpoints so that the demo
- // will run without a configuration file.
- //
- initData.properties->setProperty("Throughput.Endpoints","tcp -p 10000");
-
- //
- // Now, load the configuration file if present. Under WinCE we
- // use "config.txt" since it can be edited with pocket word.
- //
- try
- {
- initData.properties->load("config.txt");
- }
- catch(const Ice::FileException&)
- {
- }
-
- communicator = Ice::initialize(__argc, __argv, initData);
-
- Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Throughput");
- Ice::ObjectPtr object = new ThroughputI(100);
- adapter->add(object, communicator->stringToIdentity("throughput"));
- adapter->activate();
-
- //
- // Display a helpful message to the user.
- //
- ::SendMessage(editHwnd, EM_REPLACESEL,
- (WPARAM)FALSE, (LPARAM)L"Close the window to terminate the server.\r\n");
-
- //
- // Run the message pump.
- //
- MSG Msg;
- while(GetMessage(&Msg, NULL, 0, 0) > 0)
- {
- TranslateMessage(&Msg);
- DispatchMessage(&Msg);
- }
+ initData.properties = Ice::createProperties();
+
+ //
+ // Set a default value for Latency.Endpoints so that the demo
+ // will run without a configuration file.
+ //
+ initData.properties->setProperty("Throughput.Endpoints","tcp -p 10000");
+
+ //
+ // Now, load the configuration file if present. Under WinCE we
+ // use "config.txt" since it can be edited with pocket word.
+ //
+ try
+ {
+ initData.properties->load("config.txt");
+ }
+ catch(const Ice::FileException&)
+ {
+ }
+
+ communicator = Ice::initialize(__argc, __argv, initData);
+
+ Ice::ObjectAdapterPtr adapter = communicator->createObjectAdapter("Throughput");
+ Demo::ThroughputPtr servant = new ThroughputI(100);
+ adapter->add(servant, communicator->stringToIdentity("throughput"));
+ adapter->activate();
+
+ //
+ // Display a helpful message to the user.
+ //
+ ::SendMessage(editHwnd, EM_REPLACESEL,
+ (WPARAM)FALSE, (LPARAM)L"Close the window to terminate the server.\r\n");
+
+ //
+ // Run the message pump.
+ //
+ MSG Msg;
+ while(GetMessage(&Msg, NULL, 0, 0) > 0)
+ {
+ TranslateMessage(&Msg);
+ DispatchMessage(&Msg);
+ }
}
catch(const Ice::Exception& ex)
{
- TCHAR wtext[1024];
- string err = ex.toString();
- mbstowcs(wtext, err.c_str(), err.size());
- MessageBox(mainWnd, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
+ TCHAR wtext[1024];
+ string err = ex.toString();
+ mbstowcs(wtext, err.c_str(), err.size());
+ MessageBox(mainWnd, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
- status = EXIT_FAILURE;
+ status = EXIT_FAILURE;
}
if(communicator)
{
- try
- {
- communicator->destroy();
- }
- catch(const Ice::Exception& ex)
- {
- TCHAR wtext[1024];
- string err = ex.toString();
- mbstowcs(wtext, err.c_str(), err.size());
- MessageBox(mainWnd, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
-
- status = EXIT_FAILURE;
- }
+ try
+ {
+ communicator->destroy();
+ }
+ catch(const Ice::Exception& ex)
+ {
+ TCHAR wtext[1024];
+ string err = ex.toString();
+ mbstowcs(wtext, err.c_str(), err.size());
+ MessageBox(mainWnd, wtext, L"Error", MB_ICONEXCLAMATION | MB_OK);
+
+ status = EXIT_FAILURE;
+ }
}
return status;
}
diff --git a/cppe/demo/IceE/throughput/config b/cppe/demo/IceE/throughput/config
deleted file mode 100644
index cdc6b93326a..00000000000
--- a/cppe/demo/IceE/throughput/config
+++ /dev/null
@@ -1,7 +0,0 @@
-Throughput.Proxy=throughput:default -p 10000 -h 127.0.0.1
-Throughput.Endpoints=default -p 10000 -h 127.0.0.1
-
-#
-# Use faster blocking client side model by default.
-#
-Ice.Blocking=1
diff --git a/cppe/demo/IceE/throughput/config.client b/cppe/demo/IceE/throughput/config.client
new file mode 100644
index 00000000000..02ef8276f6c
--- /dev/null
+++ b/cppe/demo/IceE/throughput/config.client
@@ -0,0 +1,5 @@
+#
+# The client reads this property to create the reference to the
+# "Throughput" object in the server.
+#
+Throughput.Proxy=throughput:default -p 10000 -h 127.0.0.1
diff --git a/cppe/demo/IceE/throughput/config.server b/cppe/demo/IceE/throughput/config.server
new file mode 100644
index 00000000000..1a301bb3ed6
--- /dev/null
+++ b/cppe/demo/IceE/throughput/config.server
@@ -0,0 +1,11 @@
+#
+# The server creates one single object adapter with the name
+# "Throughput". The following line sets the endpoints for this
+# adapter.
+#
+Throughput.Endpoints=default -p 10000 -h 127.0.0.1
+
+#
+# Warn about connection exceptions
+#
+Ice.Warn.Connections=1
diff --git a/cppe/demo/IceE/workqueue/WorkQueue.cpp b/cppe/demo/IceE/workqueue/WorkQueue.cpp
index 0a209127e08..1bf33a30efe 100644
--- a/cppe/demo/IceE/workqueue/WorkQueue.cpp
+++ b/cppe/demo/IceE/workqueue/WorkQueue.cpp
@@ -24,28 +24,28 @@ public:
virtual void
run()
{
- while(1)
- {
- string item = nextItem();
- if(item == "destroy")
- {
- break;
- }
+ while(1)
+ {
+ string item = nextItem();
+ if(item == "destroy")
+ {
+ break;
+ }
- printf("work item: %s\n", item.c_str());
- IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1));
- }
+ printf("work item: %s\n", item.c_str());
+ IceUtil::ThreadControl::sleep(IceUtil::Time::seconds(1));
+ }
}
void
add(const string& item)
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor);
- if(_queue.empty())
- {
- _monitor.notify();
- }
- _queue.push_back(item);
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor);
+ if(_queue.empty())
+ {
+ _monitor.notify();
+ }
+ _queue.push_back(item);
}
private:
@@ -53,15 +53,15 @@ private:
string
nextItem()
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor);
- while(_queue.empty())
- {
- _monitor.wait();
- }
-
- string item = _queue.front();
- _queue.pop_front();
- return item;
+ IceUtil::Monitor<IceUtil::Mutex>::Lock lock(_monitor);
+ while(_queue.empty())
+ {
+ _monitor.wait();
+ }
+
+ string item = _queue.front();
+ _queue.pop_front();
+ return item;
}
@@ -76,29 +76,29 @@ main()
{
try
{
- WorkQueuePtr h = new WorkQueue();
- IceUtil::ThreadControl control = h->start();
- printf("Pushing work items");
- printf("."); fflush(stdout);
- h->add("item1");
- printf("."); fflush(stdout);
- h->add("item2");
- printf("."); fflush(stdout);
- h->add("item3");
- printf("."); fflush(stdout);
- h->add("item4");
- printf("."); fflush(stdout);
- h->add("item5");
- printf("."); fflush(stdout);
- h->add("destroy");
- printf(" ok\n");
- printf("Waiting for WorkQueue to terminate\n");
- control.join();
+ WorkQueuePtr h = new WorkQueue();
+ IceUtil::ThreadControl control = h->start();
+ printf("Pushing work items");
+ printf("."); fflush(stdout);
+ h->add("item1");
+ printf("."); fflush(stdout);
+ h->add("item2");
+ printf("."); fflush(stdout);
+ h->add("item3");
+ printf("."); fflush(stdout);
+ h->add("item4");
+ printf("."); fflush(stdout);
+ h->add("item5");
+ printf("."); fflush(stdout);
+ h->add("destroy");
+ printf(" ok\n");
+ printf("Waiting for WorkQueue to terminate\n");
+ control.join();
}
catch(const IceUtil::Exception& ex)
{
- fprintf(stderr, "%s\n", ex.toString().c_str());
- return EXIT_FAILURE;
+ fprintf(stderr, "%s\n", ex.toString().c_str());
+ return EXIT_FAILURE;
}
return EXIT_SUCCESS;