summaryrefslogtreecommitdiff
path: root/cpp/demo/Ice/winrt
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/demo/Ice/winrt')
-rw-r--r--cpp/demo/Ice/winrt/hello/MainPage.xaml19
-rw-r--r--cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp50
-rw-r--r--cpp/demo/Ice/winrt/hello/MainPage.xaml.h1
3 files changed, 62 insertions, 8 deletions
diff --git a/cpp/demo/Ice/winrt/hello/MainPage.xaml b/cpp/demo/Ice/winrt/hello/MainPage.xaml
index b1f489990c0..4712738b791 100644
--- a/cpp/demo/Ice/winrt/hello/MainPage.xaml
+++ b/cpp/demo/Ice/winrt/hello/MainPage.xaml
@@ -29,6 +29,7 @@
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
+ <RowDefinition Height="auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
@@ -50,6 +51,16 @@
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
+ <ColumnDefinition Width="1*"/>
+ <ColumnDefinition Width="9*"/>
+ </Grid.ColumnDefinitions>
+ <CheckBox Name="useDiscovery" Grid.Column="1" Unchecked="useDiscovery_Changed" Checked="useDiscovery_Changed">Use IceDiscovery</CheckBox>
+ </Grid>
+ <Grid Grid.Row="2" Margin="0, 5, 0, 0">
+ <Grid.RowDefinitions>
+ <RowDefinition Height="auto"/>
+ </Grid.RowDefinitions>
+ <Grid.ColumnDefinitions>
<ColumnDefinition Width="133*"/>
<ColumnDefinition Width="87*"/>
<ColumnDefinition Width="1106*"/>
@@ -82,7 +93,7 @@
</ComboBoxItem>
</ComboBox>
</Grid>
- <Grid Grid.Row="2" Margin="0, 5, 0, 0">
+ <Grid Grid.Row="3" Margin="0, 5, 0, 0">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
@@ -94,7 +105,7 @@
<TextBlock Grid.Column="0" Style="{StaticResource LabelStyle}">Timeout:</TextBlock>
<Slider Grid.Column="1" Name="timeout" Maximum="5" Minimum="0" Orientation="Horizontal" StepFrequency="0.1" ValueChanged="timeout_ValueChanged" Grid.ColumnSpan="2"/>
</Grid>
- <Grid Grid.Row="3" Margin="0, 5, 0, 0">
+ <Grid Grid.Row="4" Margin="0, 5, 0, 0">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
@@ -105,12 +116,12 @@
<TextBlock Grid.Column="0" Style="{StaticResource LabelStyle}">Delay:</TextBlock>
<Slider Grid.Column="1" Name="delay" Maximum="5" Minimum="0" Orientation="Horizontal" StepFrequency="0.1"/>
</Grid>
- <StackPanel Grid.Row="4" Orientation="Horizontal" Margin="0, 5, 0, 0">
+ <StackPanel Grid.Row="5" Orientation="Horizontal" Margin="0, 5, 0, 0">
<Button x:Name="hello" Content="Hello World!" Click="hello_Click"/>
<Button x:Name="shutdown" Content="Shutdown" Click="shutdown_Click"/>
<Button x:Name="flush" Content="Flush" Click="flush_Click" IsEnabled="False"/>
</StackPanel>
- <TextBlock Grid.Row="5" Style="{StaticResource LabelStyle}" Padding="5, 5, 5, 5" Text="Client Output"
+ <TextBlock Grid.Row="6" Style="{StaticResource LabelStyle}" Padding="5, 5, 5, 5" Text="Client Output"
Margin="0, 5, 0, 0"/>
<Border Grid.Row="6" BorderThickness="2" BorderBrush="Gray" Background="Gray"
Margin="0, 5, 0, 0">
diff --git a/cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp b/cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp
index e33b0369d64..0156dfba8b2 100644
--- a/cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp
+++ b/cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp
@@ -31,6 +31,8 @@ MainPage::MainPage()
InitializeComponent();
mode->SelectedIndex = 0;
Ice::InitializationData id;
+ id.properties = Ice::createProperties();
+ id.properties->setProperty("Ice.Plugin.IceDiscovery", "1"); // Enable the IceDiscovery plugin
id.dispatcher = Ice::newDispatcher(
[=](const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr&)
{
@@ -53,14 +55,23 @@ hello::MainPage::updateProxy()
}
string h = IceUtil::wstringToString(hostname->Text->Data());
- if (h.empty())
+ if (h.empty() && !useDiscovery->IsChecked->Value)
{
print("Host is empty.");
_helloPrx = 0;
return;
}
- Ice::ObjectPrx prx = _communicator->stringToProxy("hello:tcp -h " + h + " -p 10000:ssl -h " + h +
- " -p 10001:udp -h " + h + " -p 10000");
+ Ice::ObjectPrx prx;
+ if (useDiscovery->IsChecked->Value)
+ {
+ prx = _communicator->stringToProxy("hello");
+ }
+ else
+ {
+ prx = _communicator->stringToProxy("hello:tcp -h " + h + " -p 10000:ssl -h " + h +
+ " -p 10001:udp -h " + h + " -p 10000");
+ }
+
switch(mode->SelectedIndex)
{
case 0:
@@ -156,6 +167,20 @@ hello::MainPage::hello_Click(Platform::Object^ sender, Windows::UI::Xaml::Routed
},
[=](bool sentSynchronously)
{
+ if(_helloPrx)
+ {
+ Ice::ConnectionPtr con = _helloPrx->ice_getCachedConnection();
+ if(con)
+ {
+ Ice::IPConnectionInfoPtr info =
+ Ice::IPConnectionInfoPtr::dynamicCast(con->getInfo());
+ if(info)
+ {
+ hostname->Text = ref new String(
+ IceUtil::stringToWstring(info->remoteAddress).c_str());
+ }
+ }
+ }
if(this->_response)
{
return; // Response was received already.
@@ -276,7 +301,7 @@ MainPage::timeout_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Cont
void
MainPage::hostname_TextChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::TextChangedEventArgs^ e)
{
- if (hostname->Text->Length() == 0)
+ if (hostname->Text->Length() == 0 && !useDiscovery->IsChecked->Value)
{
hello->IsEnabled = false;
shutdown->IsEnabled = false;
@@ -291,8 +316,25 @@ MainPage::hostname_TextChanged(Platform::Object^ sender, Windows::UI::Xaml::Cont
updateProxy();
}
+void hello::MainPage::useDiscovery_Changed(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
+{
+ if (useDiscovery->IsChecked->Value)
+ {
+ hostname->Text = "";
+ hostname->IsEnabled = false;
+ }
+ else
+ {
+ hostname->Text = "127.0.0.1";
+ hostname->IsEnabled = true;
+ }
+ updateProxy();
+}
+
void
MainPage::print(const std::string& message)
{
output->Text = ref new String(IceUtil::stringToWstring(message).c_str());
}
+
+
diff --git a/cpp/demo/Ice/winrt/hello/MainPage.xaml.h b/cpp/demo/Ice/winrt/hello/MainPage.xaml.h
index c55e03bf834..dc5f9009649 100644
--- a/cpp/demo/Ice/winrt/hello/MainPage.xaml.h
+++ b/cpp/demo/Ice/winrt/hello/MainPage.xaml.h
@@ -35,6 +35,7 @@ private:
void mode_SelectionChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::SelectionChangedEventArgs^ e);
void timeout_ValueChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::Primitives::RangeBaseValueChangedEventArgs^ e);
void hostname_TextChanged(Platform::Object^ sender, Windows::UI::Xaml::Controls::TextChangedEventArgs^ e);
+ void useDiscovery_Changed(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
Ice::CommunicatorPtr _communicator;
Demo::HelloPrx _helloPrx;