本文整理汇总了C++中glacier2::RouterPrx类的典型用法代码示例。如果您正苦于以下问题:C++ RouterPrx类的具体用法?C++ RouterPrx怎么用?C++ RouterPrx使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RouterPrx类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: warn
void
SessionHelperI::destroyInternal(const Ice::DispatcherCallPtr& disconnected)
{
assert(_destroy);
Ice::CommunicatorPtr communicator;
Glacier2::RouterPrx router;
{
IceUtil::Mutex::Lock sync(_mutex);
router = _router;
_router = 0;
_connected = false;
communicator = _communicator;
}
if(router)
{
try
{
router->destroySession();
}
catch(const Ice::ConnectionLostException&)
{
//
// Expected if another thread invoked on an object from the session concurrently.
//
}
catch(const Glacier2::SessionNotExistException&)
{
//
// This can also occur.
//
}
catch(const std::exception& ex)
{
//
// Not expected.
//
if(communicator)
{
Ice::Warning warn(communicator->getLogger());
warn << "SessionHelper: unexpected exception when destroying the session:\n" << ex;
}
}
}
if(communicator)
{
try
{
communicator->destroy();
}
catch(...)
{
}
communicator = 0;
}
dispatchCallback(disconnected, 0);
}
开发者ID:herclogon,项目名称:ice,代码行数:59,代码来源:SessionHelper.cpp
示例2: assert
void
SessionHelperI::connected(const Glacier2::RouterPrx& router, const Glacier2::SessionPrx& session)
{
//
// Remote invocation should be done without acquire a mutex lock.
//
assert(router);
Ice::ConnectionPtr conn = router->ice_getCachedConnection();
string category = router->getCategoryForClient();
Ice::Long timeout = router->getSessionTimeout();
{
IceUtil::Mutex::Lock sync(_mutex);
_router = router;
if(_destroy)
{
//
// Run the destroyInternal in a thread. This is because it
// destroyInternal makes remote invocations.
//
IceUtil::ThreadPtr thread = new DestroyInternal(this, _callback);
thread->start().detach();
return;
}
//
// Cache the category.
//
_category = category;
//
// Assign the session after _destroy is checked.
//
_session = session;
_connected = true;
assert(!_refreshThread);
if(timeout > 0)
{
_refreshThread = new SessionRefreshThread(this, _router, (timeout)/2);
_refreshThread->start();
}
}
dispatchCallback(new Connected(_callback, this), conn);
}
开发者ID:2008hatake,项目名称:zeroc-ice,代码行数:47,代码来源:SessionHelper.cpp
示例3: ClientError
Glacier2::RouterPrx const client::getRouter(const Ice::CommunicatorPtr& comm) const {
Ice::RouterPrx prx = comm->getDefaultRouter();
if ( ! prx ) {
throw omero::ClientError(__FILE__,__LINE__,"No default router found.");
}
Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(prx);
if ( ! router ) {
throw ClientError(__FILE__, __LINE__, "Error obtaining Glacier2 router");
}
// For whatever reason, we have to set the context
// on the router context here as well.
router = Glacier2::RouterPrx::uncheckedCast(router->ice_context(comm->getImplicitContext()->getContext()));
return router;
}
开发者ID:Daniel-Walther,项目名称:openmicroscopy,代码行数:18,代码来源:client.cpp
示例4: run
virtual
void run()
{
CommunicatorPtr communicator = initialize(initData);
ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:default -p 12347 -t 10000");
Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(routerBase);
communicator->setDefaultRouter(router);
ostringstream os;
os << "userid-" << _id;
Glacier2::SessionPrx session = router->createSession(os.str(), "abc123");
communicator->getProperties()->setProperty("Ice.PrintAdapterReady", "");
ObjectAdapterPtr adapter = communicator->createObjectAdapterWithRouter("CallbackReceiverAdapter", router);
adapter->activate();
string category = router->getCategoryForClient();
{
Lock sync(*this);
_callbackReceiver = new CallbackReceiverI;
notify();
}
Identity ident;
ident.name = "callbackReceiver";
ident.category = category;
CallbackReceiverPrx receiver = CallbackReceiverPrx::uncheckedCast(adapter->add(_callbackReceiver, ident));
ObjectPrx base = communicator->stringToProxy("c1/callback:tcp -p 12010 -t 10000");
base = base->ice_oneway();
CallbackPrx callback = CallbackPrx::uncheckedCast(base);
//
// Block the CallbackReceiver in wait() to prevent the client from
// processing other incoming calls and wait to receive the callback.
//
callback->initiateWaitCallback(receiver);
test(_callbackReceiver->waitCallbackOK());
//
// Notify the main thread that the callback was received.
//
{
Lock sync(*this);
_callback = true;
notify();
}
//
// Callback the client with a large payload. This should cause
// the Glacier2 request queue thread to block trying to send the
// callback to the client because the client is currently blocked
// in CallbackReceiverI::waitCallback() and can't process more
// requests.
//
callback->initiateCallbackWithPayload(receiver);
test(_callbackReceiver->callbackWithPayloadOK());
try
{
router->destroySession();
test(false);
}
catch(const Ice::ConnectionLostException&)
{
}
catch(const Ice::LocalException&)
{
test(false);
}
communicator->destroy();
}
开发者ID:updowndown,项目名称:myffff,代码行数:72,代码来源:Client.cpp
示例5: communicator
int
CallbackClient::run(int argc, char* argv[])
{
ObjectPrx routerBase;
{
cout << "testing stringToProxy for router... " << flush;
routerBase = communicator()->stringToProxy("Glacier2/router:default -p 12347 -t 10000");
cout << "ok" << endl;
}
Glacier2::RouterPrx router;
{
cout << "testing checked cast for router... " << flush;
router = Glacier2::RouterPrx::checkedCast(routerBase);
test(router);
cout << "ok" << endl;
}
{
cout << "installing router with communicator... " << flush;
communicator()->setDefaultRouter(router);
cout << "ok" << endl;
}
{
cout << "getting the session timeout... " << flush;
Ice::Long timeout = router->getSessionTimeout();
test(timeout == 30);
cout << "ok" << endl;
}
ObjectPrx base;
{
cout << "testing stringToProxy for server object... " << flush;
base = communicator()->stringToProxy("c1/callback:tcp -p 12010 -t 10000");
cout << "ok" << endl;
}
{
cout << "trying to ping server before session creation... " << flush;
try
{
base->ice_ping();
test(false);
}
catch(const ConnectionLostException&)
{
cout << "ok" << endl;
}
}
Glacier2::SessionPrx session;
{
cout << "trying to create session with wrong password... " << flush;
try
{
session = router->createSession("userid", "xxx");
test(false);
}
catch(const Glacier2::PermissionDeniedException&)
{
cout << "ok" << endl;
}
}
{
cout << "trying to destroy non-existing session... " << flush;
try
{
router->destroySession();
test(false);
}
catch(const Glacier2::SessionNotExistException&)
{
cout << "ok" << endl;
}
}
{
cout << "creating session with correct password... " << flush;
session = router->createSession("userid", "abc123");
cout << "ok" << endl;
}
{
cout << "trying to create a second session... " << flush;
try
{
router->createSession("userid", "abc123");
test(false);
}
catch(const Glacier2::CannotCreateSessionException&)
{
cout << "ok" << endl;
}
}
//.........这里部分代码省略.........
开发者ID:updowndown,项目名称:myffff,代码行数:101,代码来源:Client.cpp
示例6: communicator
int
SessionControlClient::run(int argc, char* argv[])
{
//
// We initialize the controller on a separate port because we want
// to bypass the router for test control operations.
//
cout << "accessing test controller... " << flush;
Ice::InitializationData initData;
initData.properties = communicator()->getProperties();
Ice::CommunicatorPtr controlComm = Ice::initialize(argc, argv, initData);
TestControllerPrx controller = TestControllerPrx::checkedCast(
controlComm->stringToProxy("testController:tcp -p 12013"));
test(controller);
TestToken currentState;
TestToken newState;
currentState.expectedResult = false;
currentState.config = 0;
currentState.caseIndex = 0;
currentState.code = Initial;
controller->step(0, currentState, newState);
currentState = newState;
cout << "ok" << endl;
cout << "getting router... " << flush;
ObjectPrx routerBase = communicator()->stringToProxy("Glacier2/router:default -p 12347");
Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(routerBase);
test(router);
communicator()->setDefaultRouter(router);
cout << "ok" << endl;
Glacier2::SessionPrx sessionBase = router->createSession("userid", "abc123");
Test::TestSessionPrx currentSession = Test::TestSessionPrx::checkedCast(sessionBase);
bool printOk = false;
while(currentState.code == Running)
{
controller->step(currentSession, currentState, newState);
currentState = newState;
if(currentState.code != Running)
{
cout << "ok" << endl;
break;
}
//
// If we are running the first case for this configuration, print the configuration description.
//
if(currentState.caseIndex == 0)
{
if(printOk)
{
cout << "ok" << endl;
}
else
{
printOk = true;
}
cout << currentState.description << "... " << flush;
}
if(currentState.expectedResult)
{
BackendPrx prx = BackendPrx::uncheckedCast(communicator()->stringToProxy(currentState.testReference));
try
{
prx->check();
}
catch(const Exception& ex)
{
cerr << ex << endl;
test(false);
}
}
else
{
BackendPrx prx = BackendPrx::uncheckedCast(communicator()->stringToProxy(currentState.testReference));
try
{
prx->check();
test(false);
}
catch(const ObjectNotExistException&)
{
}
catch(const Exception& ex)
{
cerr << ex << endl;
test(false);
}
}
}
//
// Cleanup.
//
router->destroySession();
cout << "testing shutdown... " << flush;
//.........这里部分代码省略.........
开发者ID:herclogon,项目名称:ice,代码行数:101,代码来源:Client.cpp
示例7: communicator
int
SessionControlClient::run(int, char**)
{
cout << "getting router... " << flush;
ObjectPrx routerBase = communicator()->stringToProxy("Glacier2/router:" + getTestEndpoint(communicator(), 50));
Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(routerBase);
test(router);
communicator()->setDefaultRouter(router);
cout << "ok" << endl;
cout << "creating session... " << flush;
Glacier2::SessionPrx sessionBase = router->createSession("userid", "abc123");
Test::SessionPrx session = Test::SessionPrx::uncheckedCast(sessionBase);
test(session);
cout << "ok" << endl;
cout << "testing destroy... " << flush;
try
{
session->destroyFromClient();
}
catch(const Ice::LocalException&)
{
test(false);
}
try
{
session->ice_ping();
test(false);
}
catch(const Ice::ConnectionLostException&)
{
}
cout << "ok" << endl;
cout << "testing create exceptions... " << flush;
try
{
router->createSession("rejectme", "abc123");
test(false);
}
catch(const Glacier2::CannotCreateSessionException&)
{
}
try
{
router->createSession("localexception", "abc123");
test(false);
}
catch(const Glacier2::CannotCreateSessionException&)
{
}
cout << "ok" << endl;
cout << "testing shutdown... " << flush;
session = Test::SessionPrx::uncheckedCast(router->createSession("userid", "abc123"));
session->shutdown();
communicator()->setDefaultRouter(0);
ObjectPrx processBase = communicator()->stringToProxy("Glacier2/admin -f Process:" +
getTestEndpoint(communicator(), 51));
Ice::ProcessPrx process = Ice::ProcessPrx::checkedCast(processBase);
test(process);
process->shutdown();
try
{
process->ice_ping();
test(false);
}
catch(const Ice::LocalException&)
{
cout << "ok" << endl;
}
return EXIT_SUCCESS;
}
开发者ID:ming-hai,项目名称:ice,代码行数:75,代码来源:Client.cpp
示例8: communicator
int
AttackClient::run(int, char**)
{
ObjectPrx routerBase = communicator()->stringToProxy("Glacier2/router:" + getTestEndpoint(communicator(), 10));
Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(routerBase);
test(router);
communicator()->setDefaultRouter(router);
PropertyDict::const_iterator p;
PropertyDict badProxies = communicator()->getProperties()->getPropertiesForPrefix("Reject.Proxy.");
for(p = badProxies.begin(); p != badProxies.end(); ++p)
{
try
{
Glacier2::SessionPrx session = router->createSession("userid", "abc123");
}
catch(const Glacier2::CannotCreateSessionException&)
{
test("Unable to create new session" == 0);
}
BackendPrx backend = BackendPrx::uncheckedCast(communicator()->stringToProxy(p->second));
try
{
backend->ice_ping();
cerr << "Test failed on : " << p->second << endl;
test("Expected exception" == 0);
}
catch(const ConnectionLostException&)
{
//
// This is ok.
//
}
catch(const CloseConnectionException&)
{
//
// This is also ok.
//
}
catch(const ObjectNotExistException&)
{
//
// This is ok for non-address filters.
//
try
{
router->destroySession();
}
catch(...)
{
}
}
catch(const LocalException& e)
{
cerr << e << endl;
test("Unexpected local exception" == 0);
}
}
PropertyDict goodProxies = communicator()->getProperties()->getPropertiesForPrefix("Accept.Proxy.");
for(p = goodProxies.begin(); p != goodProxies.end(); ++p)
{
try
{
Glacier2::SessionPrx session = router->createSession("userid", "abc123");
}
catch(const Glacier2::CannotCreateSessionException&)
{
test("Unable to create new session" == 0);
}
BackendPrx backend = BackendPrx::uncheckedCast(communicator()->stringToProxy(p->second));
try
{
backend->ice_ping();
}
catch(const LocalException& ex)
{
cerr << p->second << endl;
cerr << ex << endl;
test("Unexpected local exception" == 0);
}
try
{
router->destroySession();
}
catch(const LocalException&)
{
//
// Expected.
//
}
}
//
// Stop using router and communicate with backend and router directly
// to shut things down.
//
communicator()->setDefaultRouter(0);
try
//.........这里部分代码省略.........
开发者ID:yuanbaopapa,项目名称:ice,代码行数:101,代码来源:Client.cpp
示例9: communicator
int
AttackClient::run(int argc, char* argv[])
{
cout << "getting router... " << flush;
ObjectPrx routerBase = communicator()->stringToProxy("Glacier2/router:default -p 12347");
Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(routerBase);
test(router);
communicator()->setDefaultRouter(router);
cout << "ok" << endl;
cout << "creating session... " << flush;
Glacier2::SessionPrx session = router->createSession("userid", "abc123");
cout << "ok" << endl;
cout << "making thousands of invocations on proxies... " << flush;
ObjectPrx backendBase = communicator()->stringToProxy("dummy:tcp -p 12010");
BackendPrx backend = BackendPrx::uncheckedCast(backendBase);
backend->ice_ping();
set<BackendPrx> backends;
string msg;
for(int i = 1; i <= 10000; ++i)
{
if(i % 100 == 0)
{
if(!msg.empty())
{
cout << string(msg.size(), '\b');
}
ostringstream s;
s << i;
msg = s.str();
cout << msg << flush;
}
Identity ident;
string::iterator p;
ident.name.resize(1); // 1 + IceUtilInternal::random() % 2);
for(p = ident.name.begin(); p != ident.name.end(); ++p)
{
*p = static_cast<char>('A' + IceUtilInternal::random() % 26);
}
ident.category.resize(IceUtilInternal::random() % 2);
for(p = ident.category.begin(); p != ident.category.end(); ++p)
{
*p = static_cast<char>('a' + IceUtilInternal::random() % 26);
}
BackendPrx newBackend = BackendPrx::uncheckedCast(backendBase->ice_identity(ident));
set<BackendPrx>::const_iterator q = backends.find(newBackend);
if(q == backends.end())
{
backends.insert(newBackend);
backend = newBackend;
}
else
{
backend = *q;
}
backend->ice_ping();
}
cout << string(msg.size(), '\b') << string(msg.size(), ' ') << string(msg.size(), '\b');
cout << "ok" << endl;
cout << "testing server and router shutdown... " << flush;
backend->shutdown();
communicator()->setDefaultRouter(0);
ObjectPrx adminBase = communicator()->stringToProxy("Glacier2/admin -f Process:tcp -h 127.0.0.1 -p 12348");
Ice::ProcessPrx process = Ice::ProcessPrx::checkedCast(adminBase);
test(process);
process->shutdown();
try
{
process->ice_ping();
test(false);
}
catch(const Ice::LocalException&)
{
cout << "ok" << endl;
}
return EXIT_SUCCESS;
}
开发者ID:bholl,项目名称:zeroc-ice,代码行数:89,代码来源:Client.cpp
示例10: createTestProperties
void
CallbackClient::run(int argc, char** argv)
{
Ice::PropertiesPtr properties = createTestProperties(argc, argv);
properties->setProperty("Ice.Warn.Connections", "0");
properties->setProperty("Ice.ThreadPool.Client.Serialize", "1");
Ice::CommunicatorHolder communicator = initialize(argc, argv, properties);
ObjectPrx routerBase = communicator->stringToProxy("Glacier2/router:" + getTestEndpoint(50));
Glacier2::RouterPrx router = Glacier2::RouterPrx::checkedCast(routerBase);
communicator->setDefaultRouter(router);
ObjectPrx base = communicator->stringToProxy("c/callback:" + getTestEndpoint());
Glacier2::SessionPrx session = router->createSession("userid", "abc123");
base->ice_ping();
CallbackPrx twoway = CallbackPrx::checkedCast(base);
CallbackPrx oneway = twoway->ice_oneway();
CallbackPrx batchOneway = twoway->ice_batchOneway();
communicator->getProperties()->setProperty("Ice.PrintAdapterReady", "0");
ObjectAdapterPtr adapter = communicator->createObjectAdapterWithRouter("CallbackReceiverAdapter", router);
adapter->activate();
string category = router->getCategoryForClient();
CallbackReceiverI* callbackReceiverImpl = new CallbackReceiverI;
ObjectPtr callbackReceiver = callbackReceiverImpl;
Identity callbackReceiverIdent;
callbackReceiverIdent.name = "callbackReceiver";
callbackReceiverIdent.category = category;
CallbackReceiverPrx twowayR =
CallbackReceiverPrx::uncheckedCast(adapter->add(callbackReceiver, callbackReceiverIdent));
CallbackReceiverPrx onewayR = twowayR->ice_oneway();
{
cout << "testing client request override... " << flush;
{
for(int i = 0; i < 5; i++)
{
oneway->initiateCallback(twowayR, 0);
oneway->initiateCallback(twowayR, 0);
callbackReceiverImpl->callbackOK(2, 0);
}
}
{
Ice::Context ctx;
ctx["_ovrd"] = "test";
for(int i = 0; i < 5; i++)
{
oneway->initiateCallback(twowayR, i, ctx);
oneway->initiateCallback(twowayR, i, ctx);
oneway->initiateCallback(twowayR, i, ctx);
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100));
test(callbackReceiverImpl->callbackOK(1, i) < 3);
}
}
cout << "ok" << endl;
}
{
cout << "testing server request override... " << flush;
Ice::Context ctx;
ctx["serverOvrd"] = "test";
for(int i = 0; i < 5; i++)
{
oneway->initiateCallback(onewayR, i, ctx);
oneway->initiateCallback(onewayR, i, ctx);
oneway->initiateCallback(onewayR, i, ctx);
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(100));
test(callbackReceiverImpl->callbackOK(1, i) < 3);
}
oneway->initiateCallback(twowayR, 0);
test(callbackReceiverImpl->callbackOK(1, 0) == 0);
int count = 0;
int nRetry = 0;
do
{
callbackReceiverImpl->hold();
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallbackWithPayload(onewayR, ctx);
oneway->initiateCallback(twowayR, 0);
IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(200 + nRetry * 200));
callbackReceiverImpl->activate();
test(callbackReceiverImpl->callbackOK(1, 0) == 0);
count = callbackReceiverImpl->callbackWithPayloadOK(0);
callbackReceiverImpl->callbackWithPayloadOK(count);
}
while(count == 10 && nRetry++ < 10);
//.........这里部分代码省略.........
开发者ID:zeroc-ice,项目名称:ice-debian-packaging,代码行数:101,代码来源:Client.cpp
示例11: assert
void
SessionHelperI::connected(const Glacier2::RouterPrx& router, const Glacier2::SessionPrx& session)
{
//
// Remote invocation should be done without acquiring a mutex lock.
//
assert(router);
Ice::ConnectionPtr conn = router->ice_getCachedConnection();
string category = router->getCategoryForClient();
Ice::Int acmTimeout = 0;
try
{
acmTimeout = router->getACMTimeout();
}
catch(const Ice::OperationNotExistException&)
{
}
if(acmTimeout <= 0)
{
acmTimeout = static_cast<Ice::Int>(router->getSessionTimeout());
}
//
// We create the callback object adapter here because createObjectAdapter internally
// makes synchronous RPCs to the router. We can't create the OA on-demand when the
// client calls objectAdapter() or addWithUUID() because they can be called from the
// GUI thread.
//
if(_useCallbacks)
{
_adapter = _communicator->createObjectAdapterWithRouter("", router);
_adapter->activate();
}
bool destroy;
{
IceUtil::Mutex::Lock sync(_mutex);
_router = router;
destroy = _destroy;
if(!_destroy)
{
//
// Cache the category.
//
_category = category;
//
// Assign the session after _destroy is checked.
//
_session = session;
_connected = true;
if(acmTimeout > 0)
{
Ice::ConnectionPtr connection = _router->ice_getCachedConnection();
assert(connection);
connection->setACM(acmTimeout, IceUtil::None, Ice::HeartbeatAlways);
connection->setCallback(new ConnectionCallbackI(this));
}
}
}
if(destroy)
{
//
// connected() is only called from the ConnectThread so it is ok to
// call destroyInternal here.
//
destroyInternal(new Disconnected(this, _callback));
}
else
{
dispatchCallback(new Connected(_callback, this), conn);
}
}
开发者ID:herclogon,项目名称:ice,代码行数:77,代码来源:SessionHelper.cpp
注:本文中的glacier2::RouterPrx类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论