summaryrefslogtreecommitdiff
path: root/cpp/test/uwp/controller
diff options
context:
space:
mode:
authorJose <jose@zeroc.com>2017-09-21 08:45:10 +0200
committerJose <jose@zeroc.com>2017-09-21 08:53:26 +0200
commit5fb4eb13230bf1c90c0f31760caaf5ec52adec95 (patch)
treed32d4b3c90a4052cfa1649cb66cdcf203e697ebc /cpp/test/uwp/controller
parentFix Windows C++ compiler detection in test scripts (diff)
downloadice-5fb4eb13230bf1c90c0f31760caaf5ec52adec95.tar.bz2
ice-5fb4eb13230bf1c90c0f31760caaf5ec52adec95.tar.xz
ice-5fb4eb13230bf1c90c0f31760caaf5ec52adec95.zip
Add support to set server address with UWP controller
Added support set the server IP address to be use by the UWP servers. This allow to run UWP servers with clients from different platforms.
Diffstat (limited to 'cpp/test/uwp/controller')
-rw-r--r--cpp/test/uwp/controller/ViewController.xaml5
-rw-r--r--cpp/test/uwp/controller/ViewController.xaml.cpp55
-rw-r--r--cpp/test/uwp/controller/ViewController.xaml.h1
3 files changed, 52 insertions, 9 deletions
diff --git a/cpp/test/uwp/controller/ViewController.xaml b/cpp/test/uwp/controller/ViewController.xaml
index 9ea1c4d9beb..de7830f076a 100644
--- a/cpp/test/uwp/controller/ViewController.xaml
+++ b/cpp/test/uwp/controller/ViewController.xaml
@@ -11,6 +11,7 @@
<Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
+ <RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
@@ -20,7 +21,9 @@
Margin="5"
VerticalAlignment="Bottom" TextWrapping="Wrap"/>
</StackPanel>
- <ListBox Margin="5" Grid.Row="1" x:Name="Output" Background="LightGray"></ListBox>
+ <ComboBox Grid.Row="1" Header="IPv4 Address" Name="ipv4Addresses " HorizontalAlignment="Stretch"
+ SelectionChanged="Hostname_SelectionChanged"></ComboBox>
+ <ListBox Margin="5" Grid.Row="2" x:Name="Output" Background="LightGray"></ListBox>
<StackPanel Grid.Row="3" VerticalAlignment="Bottom">
<TextBlock Text="Copyright (c) 2003-2017 ZeroC, Inc. All rights reserved."
Style="{StaticResource FooterStyle}"
diff --git a/cpp/test/uwp/controller/ViewController.xaml.cpp b/cpp/test/uwp/controller/ViewController.xaml.cpp
index da938e00798..b1c8d682e54 100644
--- a/cpp/test/uwp/controller/ViewController.xaml.cpp
+++ b/cpp/test/uwp/controller/ViewController.xaml.cpp
@@ -101,14 +101,14 @@ class ProcessControllerI : public ProcessController
{
public:
- ProcessControllerI(ViewController^, string);
- virtual shared_ptr<ProcessPrx> start(string, string, StringSeq, const Ice::Current&);
+ ProcessControllerI(ViewController^);
+ shared_ptr<ProcessPrx> start(string, string, StringSeq, const Ice::Current&);
virtual string getHost(string, bool, const Ice::Current&);
private:
ViewController^ _controller;
- string _hostname;
+ string _host;
};
class ControllerHelper
@@ -315,9 +315,9 @@ ProcessI::terminate(const Ice::Current& current)
return _helper->getOutput();
}
-ProcessControllerI::ProcessControllerI(ViewController^ controller, string hostname) :
+ProcessControllerI::ProcessControllerI(ViewController^ controller) :
_controller(controller),
- _hostname(hostname)
+ _host(_controller->getHost())
{
}
@@ -337,7 +337,7 @@ ProcessControllerI::start(string testSuite, string exe, StringSeq args, const Ic
string
ProcessControllerI::getHost(string, bool, const Ice::Current&)
{
- return _hostname;
+ return _host;
}
ControllerHelper::ControllerHelper(ViewController^ controller)
@@ -357,8 +357,8 @@ ControllerHelper::ControllerHelper(ViewController^ controller)
_communicator->stringToProxy("Util/ProcessControllerRegistry:tcp -h 127.0.0.1 -p 15001"));
Ice::ObjectAdapterPtr adapter = _communicator->createObjectAdapterWithEndpoints("ControllerAdapter", "");
Ice::Identity ident = { "ProcessController", "UWP"};
- auto processController = Ice::uncheckedCast<ProcessControllerPrx>(
- adapter->add(make_shared<ProcessControllerI>(controller, "127.0.0.1"), ident));
+ auto processController =
+ Ice::uncheckedCast<ProcessControllerPrx>(adapter->add(make_shared<ProcessControllerI>(controller), ident));
adapter->activate();
registerProcessController(controller, adapter, registry, processController);
@@ -390,6 +390,9 @@ ControllerHelper::registerProcessController(ViewController^ controller,
{
rethrow_exception(e);
}
+ catch(const Ice::CommunicatorDestroyedException&)
+ {
+ }
catch(const std::exception& ex)
{
ostringstream os;
@@ -409,6 +412,14 @@ ControllerHelper::registerProcessController(ViewController^ controller,
std::this_thread::sleep_for(2s);
registerProcessController(controller, adapter, registry, processController);
}
+ catch(const Ice::TimeoutException&)
+ {
+ std::this_thread::sleep_for(2s);
+ registerProcessController(controller, adapter, registry, processController);
+ }
+ catch(const Ice::CommunicatorDestroyedException&)
+ {
+ }
catch(const std::exception& ex)
{
ostringstream os;
@@ -428,6 +439,23 @@ static ControllerHelper* controllerHelper = 0;
ViewController::ViewController()
{
InitializeComponent();
+ auto hostnames = NetworkInformation::GetHostNames();
+ ipv4Addresses->Items->Append("127.0.0.1");
+ for(unsigned int i = 0; i < hostnames->Size; ++i)
+ {
+ auto hostname = hostnames->GetAt(i);
+ if(hostname->Type == Windows::Networking::HostNameType::Ipv4)
+ {
+ ipv4Addresses->Items->Append(hostname->RawName);
+ }
+ }
+ ipv4Addresses->SelectedIndex = 0;
+}
+
+string
+ViewController::getHost() const
+{
+ return Ice::wstringToString(ipv4Addresses->SelectedItem->ToString()->Data());
}
void
@@ -442,6 +470,17 @@ ViewController::OnNavigatedTo(NavigationEventArgs^)
}
void
+ViewController::Hostname_SelectionChanged(Platform::Object^, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^)
+{
+ if(controllerHelper)
+ {
+ delete controllerHelper;
+ controllerHelper = 0;
+ }
+ controllerHelper = new ControllerHelper(this);
+}
+
+void
ViewController::println(const string& s)
{
this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler(
diff --git a/cpp/test/uwp/controller/ViewController.xaml.h b/cpp/test/uwp/controller/ViewController.xaml.h
index 77852ec9bd2..d39c1d49afc 100644
--- a/cpp/test/uwp/controller/ViewController.xaml.h
+++ b/cpp/test/uwp/controller/ViewController.xaml.h
@@ -43,6 +43,7 @@ private:
friend class ControllerHelper;
HINSTANCE loadDll(const std::string&);
void println(const std::string&);
+ std::string getHost() const;
void Hostname_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
std::map<std::string, HINSTANCE> _dlls;