forked from Azure/azure-iot-sdks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainPage.xaml.cpp
37 lines (31 loc) · 1.21 KB
/
MainPage.xaml.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
//
// MainPage.xaml.cpp
// Implementation of the MainPage class.
//
#include "pch.h"
#include "MainPage.xaml.h"
using namespace CppUWPSample;
using namespace Platform;
using namespace Windows::Foundation;
using namespace Windows::Foundation::Collections;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Controls::Primitives;
using namespace Windows::UI::Xaml::Data;
using namespace Windows::UI::Xaml::Input;
using namespace Windows::UI::Xaml::Media;
using namespace Windows::UI::Xaml::Navigation;
using namespace Microsoft::Azure::Devices::Client;
using namespace concurrency;
// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
MainPage::MainPage()
{
InitializeComponent();
auto deviceClient = DeviceClient::CreateFromConnectionString(L"<replace>", TransportType::Http1);
byte dataBuffer[] = { 'H', 'e', 'l', 'l', 'o' };
auto pbuffer = ref new Platform::Array<byte>(&dataBuffer[0], _countof(dataBuffer));
auto eventMessage = ref new Message(pbuffer);
create_task(deviceClient->SendEventAsync(eventMessage)).then([] {
OutputDebugString(L"message sent successfully\n");
});
}