From 04fff25f717295c00d9cef4e52158109a8e63549 Mon Sep 17 00:00:00 2001 From: Jose Date: Thu, 25 May 2017 12:48:24 +0200 Subject: Fix (ICE-7915) - Fix UWP/JS controllers to setup the bidir connection before register --- cpp/test/uwp/controller/ViewController.xaml.cpp | 28 +++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'cpp/test/uwp/controller/ViewController.xaml.cpp') diff --git a/cpp/test/uwp/controller/ViewController.xaml.cpp b/cpp/test/uwp/controller/ViewController.xaml.cpp index 1ef4f5797f1..da938e00798 100644 --- a/cpp/test/uwp/controller/ViewController.xaml.cpp +++ b/cpp/test/uwp/controller/ViewController.xaml.cpp @@ -346,6 +346,7 @@ ControllerHelper::ControllerHelper(ViewController^ controller) initData.properties = Ice::createProperties(); initData.properties->setProperty("Ice.ThreadPool.Server.SizeMax", "10"); initData.properties->setProperty("Ice.Default.Host", "127.0.0.1"); + initData.properties->setProperty("Ice.Override.ConnectTimeout", "1000"); //initData.properties->setProperty("Ice.Trace.Network", "3"); //initData.properties->setProperty("Ice.Trace.Protocol", "1"); initData.properties->setProperty("ControllerAdapter.AdapterId", Ice::generateUUID()); @@ -369,18 +370,33 @@ ControllerHelper::registerProcessController(ViewController^ controller, const shared_ptr& registry, const shared_ptr& processController) { - registry->setProcessControllerAsync(processController, + registry->ice_pingAsync( [this, controller, adapter, registry, processController]() { auto connection = registry->ice_getCachedConnection(); connection->setAdapter(adapter); connection->setACM(5, Ice::ACMClose::CloseOff, Ice::ACMHeartbeat::HeartbeatAlways); connection->setCloseCallback([=](const shared_ptr&) - { - controller->println("connection with process controller registry closed"); - std::this_thread::sleep_for(2s); - registerProcessController(controller, adapter, registry, processController); - }); + { + controller->println("connection with process controller registry closed"); + std::this_thread::sleep_for(2s); + registerProcessController(controller, adapter, registry, processController); + }); + + registry->setProcessControllerAsync(processController, nullptr, + [controller](exception_ptr e) + { + try + { + rethrow_exception(e); + } + catch(const std::exception& ex) + { + ostringstream os; + os << "unexpected exception while connecting to process controller registry:\n" << ex.what(); + controller->println(os.str()); + } + }); }, [this, controller, adapter, registry, processController](exception_ptr e) { -- cgit v1.2.3