diff options
author | Jose <jose@zeroc.com> | 2012-08-10 23:53:37 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2012-08-10 23:53:37 +0200 |
commit | 1d5c04bb8c0e786a717e36467e17f34bcc4f1d95 (patch) | |
tree | c1c91f034589260e97033131061d536ecfc2b9cb /cpp/demo | |
parent | ICE-4702 - Poor hash algorithm (diff) | |
download | ice-1d5c04bb8c0e786a717e36467e17f34bcc4f1d95.tar.bz2 ice-1d5c04bb8c0e786a717e36467e17f34bcc4f1d95.tar.xz ice-1d5c04bb8c0e786a717e36467e17f34bcc4f1d95.zip |
C++11 ami lambda support
Diffstat (limited to 'cpp/demo')
-rw-r--r-- | cpp/demo/Glacier2/winrt/chat/App.xaml.cpp | 10 | ||||
-rw-r--r-- | cpp/demo/Glacier2/winrt/chat/App.xaml.h | 10 | ||||
-rw-r--r-- | cpp/demo/Glacier2/winrt/chat/ChatView.xaml.cpp | 25 | ||||
-rw-r--r-- | cpp/demo/Glacier2/winrt/chat/ChatView.xaml.h | 37 | ||||
-rw-r--r-- | cpp/demo/Glacier2/winrt/chat/LoginView.xaml.cpp | 20 | ||||
-rw-r--r-- | cpp/demo/Glacier2/winrt/chat/LoginView.xaml.h | 40 | ||||
-rw-r--r-- | cpp/demo/Glacier2/winrt/chat/MainPage.xaml.cpp | 116 | ||||
-rw-r--r-- | cpp/demo/Glacier2/winrt/chat/MainPage.xaml.h | 143 | ||||
-rw-r--r-- | cpp/demo/Glacier2/winrt/chat/chat.vcxproj | 4 | ||||
-rw-r--r-- | cpp/demo/Ice/winrt/bidir/App.xaml.cpp | 11 | ||||
-rw-r--r-- | cpp/demo/Ice/winrt/bidir/App.xaml.h | 10 | ||||
-rw-r--r-- | cpp/demo/Ice/winrt/bidir/MainPage.xaml.cpp | 49 | ||||
-rw-r--r-- | cpp/demo/Ice/winrt/bidir/MainPage.xaml.h | 64 | ||||
-rw-r--r-- | cpp/demo/Ice/winrt/bidir/bidir.vcxproj | 4 | ||||
-rw-r--r-- | cpp/demo/Ice/winrt/hello/App.xaml.cpp | 10 | ||||
-rw-r--r-- | cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp | 172 | ||||
-rw-r--r-- | cpp/demo/Ice/winrt/hello/MainPage.xaml.h | 69 |
17 files changed, 354 insertions, 440 deletions
diff --git a/cpp/demo/Glacier2/winrt/chat/App.xaml.cpp b/cpp/demo/Glacier2/winrt/chat/App.xaml.cpp index f551ed4bccb..826dbb0322a 100644 --- a/cpp/demo/Glacier2/winrt/chat/App.xaml.cpp +++ b/cpp/demo/Glacier2/winrt/chat/App.xaml.cpp @@ -1,7 +1,11 @@ -//
-// App.xaml.cpp
-// Implementation of the App class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "MainPage.xaml.h"
diff --git a/cpp/demo/Glacier2/winrt/chat/App.xaml.h b/cpp/demo/Glacier2/winrt/chat/App.xaml.h index 779bf1490be..b1b6a271204 100644 --- a/cpp/demo/Glacier2/winrt/chat/App.xaml.h +++ b/cpp/demo/Glacier2/winrt/chat/App.xaml.h @@ -1,7 +1,11 @@ -//
-// App.xaml.h
-// Declaration of the App class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
diff --git a/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.cpp b/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.cpp index a9c505c2aae..0b05884d269 100644 --- a/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.cpp +++ b/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.cpp @@ -1,7 +1,11 @@ -//
-// ChatView.xaml.cpp
-// Implementation of the ChatView class
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "ChatView.xaml.h"
@@ -21,8 +25,6 @@ using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
-// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
-
ChatView::ChatView()
{
InitializeComponent();
@@ -43,23 +45,12 @@ ChatView::appendMessage(String^ message) Scroller->ScrollToVerticalOffset(Scroller->ScrollableHeight);
}
-/// <summary>
-/// Invoked when this page is about to be displayed in a Frame.
-/// </summary>
-/// <param name="e">Event data that describes how this page was reached. The Parameter
-/// property is typically used to configure the page.</param>
-void ChatView::OnNavigatedTo(NavigationEventArgs^ e)
-{
- (void) e; // Unused parameter
-}
-
-
void chat::ChatView::inputKeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e)
{
if(e->Key == Windows::System::VirtualKey::Enter && !input->Text->IsEmpty())
{
string msg = IceUtil::wstringToString(input->Text->Data());
- input->Text = ref new String();
+ input->Text = "";
MainPage::instance()->coordinator()->say(msg);
}
}
diff --git a/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.h b/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.h index 15de1de2aea..6ec11949560 100644 --- a/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.h +++ b/cpp/demo/Glacier2/winrt/chat/ChatView.xaml.h @@ -1,7 +1,11 @@ -//
-// ChatView.xaml.h
-// Declaration of the ChatView class
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
@@ -9,25 +13,18 @@ namespace chat
{
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public ref class ChatView sealed
- {
- public:
-
- ChatView();
-
- void setError(Platform::String^ err);
- void appendMessage(Platform::String^ message);
-
- protected:
+public ref class ChatView sealed
+{
+public:
- virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
+ ChatView();
+ void setError(Platform::String^ err);
+ void appendMessage(Platform::String^ message);
- private:
+private:
- void inputKeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
- };
+ void inputKeyDown(Platform::Object^ sender, Windows::UI::Xaml::Input::KeyRoutedEventArgs^ e);
+};
+
}
diff --git a/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.cpp b/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.cpp index 7afa5d9320e..8c7ed5927b5 100644 --- a/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.cpp +++ b/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.cpp @@ -1,7 +1,11 @@ -//
-// LoginView.xaml.cpp
-// Implementation of the LoginView class
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "LoginView.xaml.h"
@@ -20,8 +24,6 @@ using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
-// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
-
LoginView::LoginView()
{
InitializeComponent();
@@ -36,12 +38,7 @@ LoginView::setError(String^ err) error->Text = err;
}
-/// <summary>
-/// Invoked when this page is about to be displayed in a Frame.
-/// </summary>
-/// <param name="e">Event data that describes how this page was reached. The Parameter
-/// property is typically used to configure the page.</param>
-void LoginView::OnNavigatedTo(NavigationEventArgs^ e)
+void LoginView::OnNavigatedTo(NavigationEventArgs^)
{
LoginData loginData = MainPage::instance()->coordinator()->loginData();
if(!loginData.hostname.empty())
@@ -56,7 +53,6 @@ void LoginView::OnNavigatedTo(NavigationEventArgs^ e) {
password->Password = ref new String(IceUtil::stringToWstring(loginData.password).c_str());
}
- (void) e; // Unused parameter
}
void chat::LoginView::signinClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
diff --git a/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.h b/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.h index dc4e60f5118..87317e73b49 100644 --- a/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.h +++ b/cpp/demo/Glacier2/winrt/chat/LoginView.xaml.h @@ -1,7 +1,11 @@ -//
-// LoginView.xaml.h
-// Declaration of the LoginView class
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
@@ -9,27 +13,25 @@ namespace chat
{
- ref class MainPage;
-
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public ref class LoginView sealed
- {
- public:
- LoginView();
+public ref class LoginView sealed
+{
+public:
- void setError(Platform::String^ err);
+ LoginView();
+ void setError(Platform::String^);
+ void signinCompleted()
+ {
+ signin->IsEnabled = true;
+ }
- protected:
+protected:
- virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
+ virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^) override;
- private:
+private:
- void signinClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void signinClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^);
+};
- friend ref class MainPage;
- };
}
diff --git a/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.cpp b/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.cpp index 20c74f86162..3f110ecd409 100644 --- a/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.cpp +++ b/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.cpp @@ -1,7 +1,11 @@ -//
-// MainPage.xaml.cpp
-// Implementation of the MainPage class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "MainPage.xaml.h"
@@ -24,44 +28,28 @@ using namespace Windows::UI::Xaml::Interop; using namespace std;
-// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
-
MainPage^ MainPage::_instance = nullptr;
-class DispatcherI : virtual public Ice::Dispatcher
-{
-public:
-
- DispatcherI(CoreDispatcher^ dispatcher) :
- _dispatcher(dispatcher)
- {
- }
-
- virtual void dispatch(const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr&)
- {
- _dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([=]()
- {
- call->run();
- }, CallbackContext::Any));
- }
-
-private:
-
- CoreDispatcher^ _dispatcher;
-};
-
Coordinator::Coordinator(CoreDispatcher^ dispatcher) :
_dispatcher(dispatcher)
{
}
void
-Coordinator::signIn(LoginData loginData)
+Coordinator::signIn(const LoginData& loginData)
{
_loginData = loginData;
Ice::InitializationData id;
id.properties = Ice::createProperties();
- id.dispatcher = new DispatcherI(_dispatcher);
+ id.dispatcher = Ice::newDispatcher(
+ [=](const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr&)
+ {
+ this->_dispatcher->RunAsync(
+ CoreDispatcherPriority::Normal, ref new DispatchedHandler([=]()
+ {
+ call->run();
+ }, CallbackContext::Any));
+ });
Glacier2::SessionFactoryHelperPtr factory = new Glacier2::SessionFactoryHelper(id, this);
Ice::Identity identity;
identity.name = "router";
@@ -82,9 +70,12 @@ Coordinator::say(const std::string& msg) {
try
{
- Demo::Callback_ChatSession_sayPtr cb = Demo::newCallback_ChatSession_say(this, &Coordinator::sayCallbackSuccess,
- &Coordinator::sayCallbackError);
- _chat->begin_say(msg, cb);
+ _chat->begin_say(msg, nullptr, [](const Ice::Exception& ex)
+ {
+ ostringstream os;
+ os << "Connect failed:\n" << ex << endl;
+ MainPage::instance()->setError(os.str());
+ });
}
catch(const Ice::CommunicatorDestroyedException& ex)
{
@@ -95,38 +86,11 @@ Coordinator::say(const std::string& msg) }
void
-Coordinator::sayCallbackSuccess()
-{
-}
-
-void
-Coordinator::sayCallbackError(const Ice::Exception& ex)
-{
- ostringstream os;
- os << "Connect failed:\n" << ex << endl;
- MainPage::instance()->setError(os.str());
-}
-
-void
Coordinator::createdCommunicator(const Glacier2::SessionHelperPtr&)
{
}
void
-Coordinator::setCallbackSuccess()
-{
- MainPage::instance()->setConnected(true);
-}
-
-void
-Coordinator::setCallbackError(const Ice::Exception& ex)
-{
- ostringstream os;
- os << "Connect failed:\n" << ex << endl;
- MainPage::instance()->setError(os.str());
-}
-
-void
Coordinator::connected(const Glacier2::SessionHelperPtr& session)
{
if(_session != session)
@@ -136,9 +100,17 @@ Coordinator::connected(const Glacier2::SessionHelperPtr& session) try
{
_chat = Demo::ChatSessionPrx::uncheckedCast(session->session());
- Demo::Callback_ChatSession_setCallbackPtr cb =
- Demo::newCallback_ChatSession_setCallback(this, &Coordinator::setCallbackSuccess, &Coordinator::setCallbackError);
- _chat->begin_setCallback(Demo::ChatCallbackPrx::uncheckedCast(_session->addWithUUID(this)), cb);
+ _chat->begin_setCallback(Demo::ChatCallbackPrx::uncheckedCast(_session->addWithUUID(this)),
+ []()
+ {
+ MainPage::instance()->setConnected(true);
+ },
+ [](const Ice::Exception& ex)
+ {
+ ostringstream os;
+ os << "Connect failed:\n" << ex << endl;
+ MainPage::instance()->setError(os.str());
+ });
}
catch(const Ice::CommunicatorDestroyedException& ex)
{
@@ -167,7 +139,7 @@ Coordinator::message(const string& msg, const Ice::Current&) {
try
{
- MainPage::instance()->_chatView->appendMessage(ref new String(IceUtil::stringToWstring(msg).c_str()));
+ MainPage::instance()->appendMessage(ref new String(IceUtil::stringToWstring(msg).c_str()));
}
catch(const Ice::CommunicatorDestroyedException& ex)
{
@@ -195,6 +167,12 @@ MainPage::MainPage() setConnected(false);
}
+void
+MainPage::appendMessage(String^ message)
+{
+ _chatView->appendMessage(message);
+}
+
MainPage^
MainPage::instance()
{
@@ -217,7 +195,7 @@ MainPage::setConnected(bool connected) }
TypeName page = {pageName, TypeKind::Custom};
main->Navigate(page, this);
- _loginView->signin->IsEnabled = true;
+ _loginView->signinCompleted();
}
void
@@ -227,16 +205,6 @@ MainPage::setError(const std::string& err) _loginView->setError(ref new String(IceUtil::stringToWstring(err).c_str()));
}
-/// <summary>
-/// Invoked when this page is about to be displayed in a Frame.
-/// </summary>
-/// <param name="e">Event data that describes how this page was reached. The Parameter
-/// property is typically used to configure the page.</param>
-void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
-{
- (void) e; // Unused parameter
-}
-
void chat::MainPage::signoutClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
_coordinator->destroy();
diff --git a/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.h b/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.h index 717930ecc99..9b503992663 100644 --- a/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.h +++ b/cpp/demo/Glacier2/winrt/chat/MainPage.xaml.h @@ -1,7 +1,11 @@ -//
-// MainPage.xaml.h
-// Declaration of the MainPage class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
@@ -14,89 +18,80 @@ namespace chat
{
- struct LoginData
- {
- std::string hostname;
- std::string username;
- std::string password;
- };
+struct LoginData
+{
+ std::string hostname;
+ std::string username;
+ std::string password;
+};
- class Coordinator : virtual public Glacier2::SessionCallback,
- virtual public Demo::ChatCallback
- {
- public:
+class Coordinator : virtual public Glacier2::SessionCallback,
+ virtual public Demo::ChatCallback
+{
+public:
- Coordinator(Windows::UI::Core::CoreDispatcher^);
+ Coordinator(Windows::UI::Core::CoreDispatcher^);
- void signIn(LoginData);
- LoginData loginData();
+ void signIn(const LoginData&);
+ LoginData loginData();
- //
- // Session callback
- //
- virtual void createdCommunicator(const Glacier2::SessionHelperPtr& session);
- virtual void connected(const Glacier2::SessionHelperPtr&);
- virtual void disconnected(const Glacier2::SessionHelperPtr&);
- virtual void connectFailed(const Glacier2::SessionHelperPtr&, const Ice::Exception&);
+ //
+ // Session callback
+ //
+ virtual void createdCommunicator(const Glacier2::SessionHelperPtr&);
+ virtual void connected(const Glacier2::SessionHelperPtr&);
+ virtual void disconnected(const Glacier2::SessionHelperPtr&);
+ virtual void connectFailed(const Glacier2::SessionHelperPtr&, const Ice::Exception&);
- //
- // Chat callback
- //
- virtual void message(const std::string& data, const Ice::Current&);
-
- void setCallbackSuccess();
- void setCallbackError(const Ice::Exception&);
-
- void say(const std::string&);
- void sayCallbackSuccess();
- void sayCallbackError(const Ice::Exception&);
+ //
+ // Chat callback
+ //
+ virtual void message(const std::string& data, const Ice::Current&);
+
+ //
+ // Chat session.
+ //
+ void say(const std::string&);
+ void destroy();
+
+private:
+
+ Demo::ChatSessionPrx _chat;
+ Glacier2::SessionHelperPtr _session;
+ Windows::UI::Core::CoreDispatcher^ _dispatcher;
+ LoginData _loginData;
+};
+typedef IceUtil::Handle<Coordinator> CoordinatorPtr;
+
+public ref class MainPage sealed
+{
+public:
- void destroy();
+ MainPage();
- private:
+ static MainPage^ instance();
+ void setConnected(bool);
+ void appendMessage(Platform::String^);
- Demo::ChatSessionPrx _chat;
- Glacier2::SessionHelperPtr _session;
- Windows::UI::Core::CoreDispatcher^ _dispatcher;
- LoginData _loginData;
- };
- typedef IceUtil::Handle<Coordinator> CoordinatorPtr;
+private:
+
+ virtual void setError(const std::string&);
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public ref class MainPage sealed
+ CoordinatorPtr coordinator()
{
- public:
-
- MainPage();
-
- static MainPage^ instance();
-
- void setConnected(bool);
-
- protected:
-
- virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
-
- private:
-
- virtual void setError(const std::string&);
+ return _coordinator;
+ }
+ CoordinatorPtr _coordinator;
- CoordinatorPtr coordinator()
- {
- return _coordinator;
- }
- CoordinatorPtr _coordinator;
+ static MainPage^ _instance;
- static MainPage^ _instance;
+ friend ref class LoginView;
+ friend ref class ChatView;
+ friend class Coordinator;
- friend ref class LoginView;
- friend ref class ChatView;
- friend class Coordinator;
+ LoginView^ _loginView;
+ ChatView^ _chatView;
+ void signoutClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+};
- LoginView^ _loginView;
- ChatView^ _chatView;
- void signoutClick(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
- };
}
diff --git a/cpp/demo/Glacier2/winrt/chat/chat.vcxproj b/cpp/demo/Glacier2/winrt/chat/chat.vcxproj index f10b56c07e7..5a422517ed5 100644 --- a/cpp/demo/Glacier2/winrt/chat/chat.vcxproj +++ b/cpp/demo/Glacier2/winrt/chat/chat.vcxproj @@ -209,10 +209,10 @@ </ClCompile>
</ItemGroup>
<ItemGroup>
- <SDKReference Include="IceWinRT, Version=3.4" />
+ <Text Include="README.txt" />
</ItemGroup>
<ItemGroup>
- <Text Include="README.txt" />
+ <SDKReference Include="IceWinRT, Version=3.4" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/cpp/demo/Ice/winrt/bidir/App.xaml.cpp b/cpp/demo/Ice/winrt/bidir/App.xaml.cpp index d2b443c3643..d3b64f4d024 100644 --- a/cpp/demo/Ice/winrt/bidir/App.xaml.cpp +++ b/cpp/demo/Ice/winrt/bidir/App.xaml.cpp @@ -1,7 +1,12 @@ -//
-// App.xaml.cpp
-// Implementation of the App class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
#include "pch.h"
#include "MainPage.xaml.h"
diff --git a/cpp/demo/Ice/winrt/bidir/App.xaml.h b/cpp/demo/Ice/winrt/bidir/App.xaml.h index 7cce50550bb..103a440e38e 100644 --- a/cpp/demo/Ice/winrt/bidir/App.xaml.h +++ b/cpp/demo/Ice/winrt/bidir/App.xaml.h @@ -1,7 +1,11 @@ -//
-// App.xaml.h
-// Declaration of the App class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
diff --git a/cpp/demo/Ice/winrt/bidir/MainPage.xaml.cpp b/cpp/demo/Ice/winrt/bidir/MainPage.xaml.cpp index 11f76249417..6f234cdfec5 100644 --- a/cpp/demo/Ice/winrt/bidir/MainPage.xaml.cpp +++ b/cpp/demo/Ice/winrt/bidir/MainPage.xaml.cpp @@ -1,7 +1,11 @@ -//
-// MainPage.xaml.cpp
-// Implementation of the MainPage class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "MainPage.xaml.h"
@@ -29,23 +33,11 @@ CallbackReceiverI::callback(Ice::Int num, const Ice::Current& current) _page->callback(num, current);
}
-// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
-
MainPage::MainPage()
{
InitializeComponent();
}
-/// <summary>
-/// Invoked when this page is about to be displayed in a Frame.
-/// </summary>
-/// <param name="e">Event data that describes how this page was reached. The Parameter
-/// property is typically used to configure the page.</param>
-void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
-{
- (void) e; // Unused parameter
-}
-
void bidir::MainPage::startClient_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e)
{
try
@@ -58,7 +50,8 @@ void bidir::MainPage::startClient_Click(Platform::Object^ sender, Windows::UI::X _communicator = Ice::initialize(initData);
CallbackSenderPrx server = CallbackSenderPrx::checkedCast(
- _communicator->stringToProxy("sender:tcp -h " + IceUtil::wstringToString(hostname->Text->Data()) + " -p 10000"));
+ _communicator->stringToProxy("sender:tcp -h " + IceUtil::wstringToString(hostname->Text->Data()) +
+ " -p 10000"));
if(!server)
{
@@ -75,7 +68,14 @@ void bidir::MainPage::startClient_Click(Platform::Object^ sender, Windows::UI::X adapter->add(cr, ident);
adapter->activate();
server->ice_getConnection()->setAdapter(adapter);
- server->addClient(ident);
+ server->begin_addClient(ident, nullptr, [=](const Ice::Exception& ex)
+ {
+ ostringstream os;
+ os << ex << endl;
+ print(os.str());
+ startClient->IsEnabled = true;
+ stopClient->IsEnabled = false;
+ });
}
catch(const Ice::Exception& ex)
{
@@ -121,10 +121,13 @@ bidir::MainPage::callback(Ice::Int num, const Ice::Current&) void
bidir::MainPage::print(const std::string& message)
{
- this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal, ref new DispatchedHandler([=] ()
- {
- output->Text += ref new String(IceUtil::stringToWstring(message).c_str());
- output->UpdateLayout();
- scroller->ScrollToVerticalOffset(scroller->ScrollableHeight);
- }, CallbackContext::Any));
+ this->Dispatcher->RunAsync(CoreDispatcherPriority::Normal,
+ ref new DispatchedHandler(
+ [=] ()
+ {
+ output->Text += ref new String(IceUtil::stringToWstring(message).c_str());
+ output->UpdateLayout();
+ scroller->ScrollToVerticalOffset(scroller->ScrollableHeight);
+ },
+ CallbackContext::Any));
}
diff --git a/cpp/demo/Ice/winrt/bidir/MainPage.xaml.h b/cpp/demo/Ice/winrt/bidir/MainPage.xaml.h index cec23cb50d5..a68c98d50c8 100644 --- a/cpp/demo/Ice/winrt/bidir/MainPage.xaml.h +++ b/cpp/demo/Ice/winrt/bidir/MainPage.xaml.h @@ -1,7 +1,11 @@ -//
-// MainPage.xaml.h
-// Declaration of the MainPage class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
@@ -12,44 +16,38 @@ namespace bidir
{
- ref class MainPage;
+ref class MainPage;
- class CallbackReceiverI : public Demo::CallbackReceiver
- {
- public:
+class CallbackReceiverI : public Demo::CallbackReceiver
+{
+public:
- CallbackReceiverI(MainPage^ page) : _page(page)
- {
- }
+ CallbackReceiverI(MainPage^ page) : _page(page)
+ {
+ }
- virtual void
- callback(Ice::Int, const Ice::Current&);
+ virtual void
+ callback(Ice::Int, const Ice::Current&);
- private:
+private:
- MainPage^ _page;
- };
-
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public ref class MainPage sealed
- {
- public:
- MainPage();
+ MainPage^ _page;
+};
- protected:
+public ref class MainPage sealed
+{
+public:
+ MainPage();
- virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
+private:
- private:
+ friend class CallbackReceiverI;
- friend class CallbackReceiverI;
+ void callback(Ice::Int, const Ice::Current&);
+ void print(const std::string&);
+ void startClient_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void stopClient_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ Ice::CommunicatorPtr _communicator;
+};
- void callback(Ice::Int, const Ice::Current&);
- void print(const std::string&);
- void startClient_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
- void stopClient_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
- Ice::CommunicatorPtr _communicator;
- };
}
diff --git a/cpp/demo/Ice/winrt/bidir/bidir.vcxproj b/cpp/demo/Ice/winrt/bidir/bidir.vcxproj index 275b3cabf19..855d494f803 100644 --- a/cpp/demo/Ice/winrt/bidir/bidir.vcxproj +++ b/cpp/demo/Ice/winrt/bidir/bidir.vcxproj @@ -189,10 +189,10 @@ </ClCompile>
</ItemGroup>
<ItemGroup>
- <SDKReference Include="IceWinRT, Version=3.4" />
+ <Text Include="README.txt" />
</ItemGroup>
<ItemGroup>
- <Text Include="README.txt" />
+ <SDKReference Include="IceWinRT, Version=3.4" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
diff --git a/cpp/demo/Ice/winrt/hello/App.xaml.cpp b/cpp/demo/Ice/winrt/hello/App.xaml.cpp index e23a2601ed3..dd08ad621d1 100644 --- a/cpp/demo/Ice/winrt/hello/App.xaml.cpp +++ b/cpp/demo/Ice/winrt/hello/App.xaml.cpp @@ -1,7 +1,11 @@ -//
-// App.xaml.cpp
-// Implementation of the App class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "MainPage.xaml.h"
diff --git a/cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp b/cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp index 25910c04340..711291d6bb5 100644 --- a/cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp +++ b/cpp/demo/Ice/winrt/hello/MainPage.xaml.cpp @@ -1,7 +1,11 @@ -//
-// MainPage.xaml.cpp
-// Implementation of the MainPage class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#include "pch.h"
#include "MainPage.xaml.h"
@@ -22,105 +26,29 @@ using namespace Windows::UI::Xaml::Input; using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
-class DispatcherI : virtual public Ice::Dispatcher
-{
-public:
-
- DispatcherI(CoreDispatcher^ dispatcher) :
- _dispatcher(dispatcher)
- {
- }
-
- virtual void dispatch(const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr&)
- {
- _dispatcher->RunAsync(CoreDispatcherPriority::Normal,
- ref new DispatchedHandler([=]()
- {
- call->run();
- }, CallbackContext::Any));
- }
-
-private:
-
- CoreDispatcher^ _dispatcher;
-};
-
-// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
-
MainPage::MainPage()
{
InitializeComponent();
mode->SelectedIndex = 0;
Ice::InitializationData id;
- id.dispatcher = new DispatcherI(this->Dispatcher);
+ id.dispatcher = Ice::newDispatcher(
+ [=](const Ice::DispatcherCallPtr& call, const Ice::ConnectionPtr&)
+ {
+ this->Dispatcher->RunAsync(
+ CoreDispatcherPriority::Normal, ref new DispatchedHandler([=]()
+ {
+ call->run();
+ }, CallbackContext::Any));
+ });
_communicator = Ice::initialize(id);
}
-/// <summary>
-/// Invoked when this page is about to be displayed in a Frame.
-/// </summary>
-/// <param name="e">Event data that describes how this page was reached. The Parameter
-/// property is typically used to configure the page.</param>
-void MainPage::OnNavigatedTo(NavigationEventArgs^ e)
-{
- (void) e; // Unused parameter
-}
-
-HelloCallback::HelloCallback(MainPage^ page) :
- _page(page)
-{
-}
-
-void
-HelloCallback::helloSent(bool sent)
-{
- _page->helloSent(sent);
-}
-
-void
-HelloCallback::helloSuccess()
-{
- _page->helloSuccess();
-}
-
-void
-HelloCallback::helloFailure(const Ice::Exception& ex)
-{
- _page->helloFailure(ex);
-}
-
-void
-hello::MainPage::helloSuccess()
-{
- print("Ready.");
-}
-
-void
-hello::MainPage::helloFailure(const Ice::Exception& ex)
-{
- ostringstream os;
- os << ex;
- print(os.str());
-}
-
-void
-hello::MainPage::helloSent(bool)
-{
- if(mode->SelectedIndex == 0 || mode->SelectedIndex == 1)
- {
- print("Waiting for response.");
- }
- else
- {
- print("Ready.");
- }
-}
-
Demo::HelloPrx
hello::MainPage::proxy()
{
string h = IceUtil::wstringToString(hostname->Text->Data());
- Ice::ObjectPrx prx = _communicator->stringToProxy("hello:tcp -h " + h + " -p 10000:ssl -h " + h + " -p 10001:udp -h " + h + " -p 10000");
+ Ice::ObjectPrx prx = _communicator->stringToProxy("hello:tcp -h " + h + " -p 10000:ssl -h " + h +
+ " -p 10001:udp -h " + h + " -p 10000");
switch(mode->SelectedIndex)
{
case 0:
@@ -196,16 +124,52 @@ hello::MainPage::hello_Click(Platform::Object^ sender, Windows::UI::Xaml::Routed if(!isBatch())
{
print("Sending sayHello request.");
- Demo::Callback_Hello_sayHelloPtr cb =
- Demo::newCallback_Hello_sayHello(new HelloCallback(this),
- &HelloCallback::helloSuccess,
- &HelloCallback::helloFailure,
- &HelloCallback::helloSent);
- prx->begin_sayHello(static_cast<int>(delay->Value * 1000), cb);
+ _response = false;
+ hello->IsEnabled = false;
+ int deliveryMode = mode->SelectedIndex;
+ Ice::AsyncResultPtr result = prx->begin_sayHello(static_cast<int>(delay->Value * 1000),
+ [=]()
+ {
+ hello->IsEnabled = true;
+ this->_response = true;
+ print("Ready.");
+ },
+ [=](const Ice::Exception& ex)
+ {
+ hello->IsEnabled = true;
+ this->_response = true;
+ ostringstream os;
+ os << ex;
+ print(os.str());
+ },
+ [=](bool sentSynchronously)
+ {
+ if(this->_response)
+ {
+ return; // Response was received already.
+ }
+ if(deliveryMode <= 1)
+ {
+ print("Waiting for response.");
+ }
+ else if(!sentSynchronously)
+ {
+ print("Ready.");
+ }
+ });
+
+ if(!result->sentSynchronously())
+ {
+ print("Sending request");
+ }
+ else if(deliveryMode > 1)
+ {
+ print("Ready");
+ }
}
else
{
- print("Queued sayHello request.");
+ print("Queued hello request.");
prx->sayHello((int)(delay->Value * 1000));
flush->IsEnabled = true;
}
@@ -243,10 +207,16 @@ void hello::MainPage::flush_Click(Platform::Object^ sender, Windows::UI::Xaml::R try
{
flush->IsEnabled = false;
- Ice::Callback_Communicator_flushBatchRequestsPtr cb =
- Ice::newCallback_Communicator_flushBatchRequests(new HelloCallback(this), &HelloCallback::helloFailure);
- _communicator->begin_flushBatchRequests(cb);
- print("Flushed batch requests.");
+ _communicator->begin_flushBatchRequests([=](const Ice::Exception& ex)
+ {
+ ostringstream os;
+ os << ex;
+ print(os.str());
+ },
+ [=](bool)
+ {
+ print("Flushed batch requests.");
+ });
}
catch(const Ice::Exception& ex)
{
diff --git a/cpp/demo/Ice/winrt/hello/MainPage.xaml.h b/cpp/demo/Ice/winrt/hello/MainPage.xaml.h index 0ad44475d25..4bf197f8447 100644 --- a/cpp/demo/Ice/winrt/hello/MainPage.xaml.h +++ b/cpp/demo/Ice/winrt/hello/MainPage.xaml.h @@ -1,7 +1,11 @@ -//
-// MainPage.xaml.h
-// Declaration of the MainPage class.
+// **********************************************************************
//
+// Copyright (c) 2003-2012 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
#pragma once
@@ -12,56 +16,25 @@ namespace hello
{
- ref class MainPage;
-
- class HelloCallback : virtual public IceUtil::Shared
- {
- public:
-
- HelloCallback(MainPage^);
-
- void helloSent(bool);
-
- void helloSuccess();
- void helloFailure(const Ice::Exception&);
-
- private:
-
- MainPage^ _page;
- };
- typedef IceUtil::Handle<HelloCallback> HelloCallbackPtr;
-
- /// <summary>
- /// An empty page that can be used on its own or navigated to within a Frame.
- /// </summary>
- public ref class MainPage sealed
- {
- public:
-
- MainPage();
-
- protected:
-
- virtual void OnNavigatedTo(Windows::UI::Xaml::Navigation::NavigationEventArgs^ e) override;
-
+public ref class MainPage sealed
+{
+public:
- private:
+ MainPage();
- friend class HelloCallback;
+private:
- Demo::HelloPrx proxy();
- bool isBatch();
+ Demo::HelloPrx proxy();
+ bool isBatch();
+ void print(const std::string&);
- void helloSuccess();
- void helloFailure(const Ice::Exception& ex);
- void helloSent(bool);
- void print(const std::string&);
+ void hello_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void shutdown_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ void flush_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
- void hello_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
- void shutdown_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
- void flush_Click(Platform::Object^ sender, Windows::UI::Xaml::RoutedEventArgs^ e);
+ Ice::CommunicatorPtr _communicator;
+ bool _response;
+};
- Ice::CommunicatorPtr _communicator;
- };
}
|