diff --git a/README.md b/README.md
index a042759b66..44b623dde3 100644
--- a/README.md
+++ b/README.md
@@ -413,7 +413,10 @@ For additional Windows samples, see [Windows on GitHub](http://microsoft.github.
diff --git a/Samples/AdaptiveStreaming/cs/Scenario2_EventHandlers.xaml.cs b/Samples/AdaptiveStreaming/cs/Scenario2_EventHandlers.xaml.cs
index 6d5fecc4fb..fd33a1009d 100644
--- a/Samples/AdaptiveStreaming/cs/Scenario2_EventHandlers.xaml.cs
+++ b/Samples/AdaptiveStreaming/cs/Scenario2_EventHandlers.xaml.cs
@@ -341,7 +341,7 @@ private void Source_OpenOperationCompleted(MediaSource sender, MediaSourceOpenOp
// This extension method in MediaPlaybackItemStringExtensions dumps all the properties from all the tracks.
var allProperties = item.ToFormattedString();
- Log(allProperties);
+ Log($"MediaPlaybackItem nested properties: {allProperties}");
// The AdaptiveMediaSource can manage multiple video tracks internally,
// but only a single video track is exposed in the MediaPlaybackItem, not a collection.
}
@@ -354,6 +354,7 @@ private void RegisterForMediaPlaybackItemEvents(MediaPlaybackItem item)
{
item.AudioTracks.SelectedIndexChanged += AudioTracks_SelectedIndexChanged;
item.AudioTracksChanged += Item_AudioTracksChanged;
+ item.VideoTracksChanged += Item_VideoTracksChanged;
item.TimedMetadataTracksChanged += Item_TimedMetadataTracksChanged;
}
@@ -365,11 +366,16 @@ private void UnregisterForMediaPlaybackItemEvents(MediaPlaybackItem item)
}
item.AudioTracks.SelectedIndexChanged -= AudioTracks_SelectedIndexChanged;
item.AudioTracksChanged -= Item_AudioTracksChanged;
+ item.VideoTracksChanged -= Item_VideoTracksChanged;
item.TimedMetadataTracksChanged -= Item_TimedMetadataTracksChanged;
foreach (AudioTrack audioTrack in item.AudioTracks)
{
audioTrack.OpenFailed -= AudioTrack_OpenFailed;
}
+ foreach (VideoTrack videoTrack in item.VideoTracks)
+ {
+ videoTrack.OpenFailed -= VideoTrack_OpenFailed;
+ }
}
private void AudioTracks_SelectedIndexChanged(ISingleSelectMediaTrackList sender, object args)
@@ -412,6 +418,25 @@ private void Item_AudioTracksChanged(MediaPlaybackItem sender, IVectorChangedEve
}
}
+ private void Item_VideoTracksChanged(MediaPlaybackItem sender, IVectorChangedEventArgs args)
+ {
+ Log($"item.VideoTracksChanged: CollectionChange:{args.CollectionChange} Index:{args.Index} Total:{sender.VideoTracks.Count}");
+
+ switch (args.CollectionChange)
+ {
+ case CollectionChange.Reset:
+ foreach (VideoTrack track in sender.VideoTracks)
+ {
+ track.OpenFailed += VideoTrack_OpenFailed;
+ }
+ break;
+ case CollectionChange.ItemInserted:
+ VideoTrack newTrack = sender.VideoTracks[(int)args.Index];
+ newTrack.OpenFailed += VideoTrack_OpenFailed;
+ break;
+ }
+ }
+
private void Item_TimedMetadataTracksChanged(MediaPlaybackItem sender, IVectorChangedEventArgs args)
{
Log($"item.TimedMetadataTracksChanged: CollectionChange:{args.CollectionChange} Index:{args.Index} Total:{sender.TimedMetadataTracks.Count}");
@@ -425,6 +450,12 @@ private void AudioTrack_OpenFailed(AudioTrack sender, AudioTrackOpenFailedEventA
Log($"AudioTrack.OpenFailed: ExtendedError:{args.ExtendedError} DecoderStatus:{sender.SupportInfo.DecoderStatus} MediaSourceStatus:{sender.SupportInfo.MediaSourceStatus}");
}
+ private void VideoTrack_OpenFailed(VideoTrack sender, VideoTrackOpenFailedEventArgs args)
+ {
+ Log($"VideoTrack.OpenFailed: ExtendedError:{args.ExtendedError} DecoderStatus:{sender.SupportInfo.DecoderStatus} MediaSourceStatus:{sender.SupportInfo.MediaSourceStatus}");
+ }
+
+
#endregion
#region AdaptiveMediaSource Event Handlers
diff --git a/Samples/AllJoyn/shared/AllJoynHelpers.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/AllJoynHelpers.h
similarity index 87%
rename from Samples/AllJoyn/shared/AllJoynHelpers.h
rename to Samples/AllJoyn/Common/Scenario1WinRTComponent/AllJoynHelpers.h
index 170e22504b..360af60c5d 100644
--- a/Samples/AllJoyn/shared/AllJoynHelpers.h
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/AllJoynHelpers.h
@@ -9,24 +9,13 @@
//
//*********************************************************
//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// Tool: AllJoynCodeGenerator.exe
-//
-// This tool is located in the Windows 10 SDK and the Windows 10 AllJoyn
-// Visual Studio Extension in the Visual Studio Gallery.
+//
+// This code was generated by a tool.
//
-// The generated code should be packaged in a Windows 10 C++/CX Runtime
-// Component which can be consumed in any UWP-supported language using
-// APIs that are available in Windows.Devices.AllJoyn.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
-// Using AllJoynCodeGenerator - Invoke the following command with a valid
-// Introspection XML file and a writable output directory:
-// AllJoynCodeGenerator -i -o
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
//
//-----------------------------------------------------------------------------
#pragma once
@@ -46,6 +35,23 @@ if (Windows::Devices::AllJoyn::AllJoynStatus::Ok != alljoynStatus) \
} \
}
+namespace com { namespace microsoft { namespace Samples { namespace SecureInterface {
+
+public interface class ISignalEmitter
+{
+ property Windows::Devices::AllJoyn::AllJoynBusObject^ BusObject
+ {
+ Windows::Devices::AllJoyn::AllJoynBusObject^ get();
+ }
+
+ property Windows::Devices::AllJoyn::AllJoynSession^ Session
+ {
+ Windows::Devices::AllJoyn::AllJoynSession^ get();
+ }
+};
+
+} } } }
+
class AllJoynHelpers
{
public:
@@ -53,6 +59,10 @@ class AllJoynHelpers
// function gets the underlying alljoyn_busattachment.
static alljoyn_busattachment GetInternalBusAttachment(_In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment);
+ // The Windows::Devices::AllJoyn::AllJoynBusObject class wraps the alljoyn_busobject type. This
+ // function gets the underlying alljoyn_busobject.
+ static alljoyn_busobject AllJoynHelpers::GetInternalBusObject(_In_ Windows::Devices::AllJoyn::AllJoynBusObject^ busObject);
+
// Create the alljoyn_interfacedescriptions described in introspectionXml and add them to the busAttachment.
static QStatus CreateInterfaces(_Inout_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment, _In_ PCSTR introspectionXml);
@@ -69,21 +79,6 @@ class AllJoynHelpers
// Determine whether the supplied set of AuthenticationMechanisms is sufficient for securing an AllJoyn connection.
static bool CanSecure(_In_ Windows::Foundation::Collections::IVector^ authenticationMechanisms);
- // Callback for alljoyn_about_announced_ptr.
- // This callback expects the context to be of type T, which must implement the OnAnnounce function.
- template
- static void AJ_CALL AnnounceHandler(
- _In_ const void* context,
- _In_ PCSTR name,
- _In_ uint16_t version,
- _In_ alljoyn_sessionport port,
- _In_ alljoyn_msgarg objectDescriptionArg,
- _In_ const alljoyn_msgarg aboutDataArg)
- {
- T^ caller = static_cast(context)->Resolve();
- caller->OnAnnounce(name, version, port, objectDescriptionArg, aboutDataArg);
- }
-
// Callback for alljoyn_proxybusobject_listener_propertieschanged_ptr.
// This callback expects the context to be of type T, which must implement the OnPropertyChanged function.
template
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/ISecureInterfaceService.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/ISecureInterfaceService.h
index b0a805a5eb..14b2c214bb 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/ISecureInterfaceService.h
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/ISecureInterfaceService.h
@@ -25,14 +25,17 @@ namespace com { namespace microsoft { namespace Samples { namespace SecureInterf
public interface class ISecureInterfaceService
{
public:
+ // "Concatenate two input strings and returns the concatenated string as output"
// Implement this function to handle calls to the Concatenate method.
Windows::Foundation::IAsyncOperation^ ConcatenateAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info , _In_ Platform::String^ interfaceMemberInStr1, _In_ Platform::String^ interfaceMemberInStr2);
+ // "Determine if the output of the Concatenate method is returned as upper case string or not"
// Implement this function to handle requests for the value of the IsUpperCaseEnabled property.
//
// Currently, info will always be null, because no information is available about the requestor.
Windows::Foundation::IAsyncOperation^ GetIsUpperCaseEnabledAsync(Windows::Devices::AllJoyn::AllJoynMessageInfo^ info);
+ // "Determine if the output of the Concatenate method is returned as upper case string or not"
// Implement this function to handle requests to set the IsUpperCaseEnabled property.
//
// Currently, info will always be null, because no information is available about the requestor.
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj b/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj
index f956dd8e4a..b418745e04 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj
@@ -221,18 +221,18 @@
-
+
+
-
@@ -247,11 +247,11 @@
Create
+
-
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj.filters b/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj.filters
index 3288c2691e..c0e053639e 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj.filters
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/Scenario1WinRTComponent.vcxproj.filters
@@ -11,27 +11,27 @@
+
-
-
+
+
-
\ No newline at end of file
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.cpp
index 60c5a14347..f65069e25c 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.cpp
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.cpp
@@ -28,59 +28,38 @@ using namespace Windows::Devices::AllJoyn;
using namespace com::microsoft::Samples::SecureInterface;
std::map SecureInterfaceConsumer::SourceInterfaces;
+PCSTR SecureInterfaceConsumer::m_interfaceName = "com.microsoft.Samples.SecureInterface";
SecureInterfaceConsumer::SecureInterfaceConsumer(AllJoynBusAttachment^ busAttachment)
: m_busAttachment(busAttachment),
m_proxyBusObject(nullptr),
- m_busObject(nullptr),
- m_sessionListener(nullptr),
- m_sessionId(0)
+ m_busObject(nullptr)
{
m_weak = new WeakReference(this);
m_signals = ref new SecureInterfaceSignals();
m_nativeBusAttachment = AllJoynHelpers::GetInternalBusAttachment(m_busAttachment);
-}
-SecureInterfaceConsumer::~SecureInterfaceConsumer()
-{
- AllJoynBusObjectManager::ReleaseBusObject(m_nativeBusAttachment, AllJoynHelpers::PlatformToMultibyteString(ServiceObjectPath).data());
- if (SessionListener != nullptr)
- {
- alljoyn_busattachment_setsessionlistener(m_nativeBusAttachment, m_sessionId, nullptr);
- alljoyn_sessionlistener_destroy(SessionListener);
- }
- if (nullptr != ProxyBusObject)
- {
- alljoyn_proxybusobject_destroy(ProxyBusObject);
- }
- delete m_weak;
-}
+ GUID result;
+ HRESULT hr = CoCreateGuid(&result);
-void SecureInterfaceConsumer::OnSessionLost(_In_ alljoyn_sessionid sessionId, _In_ alljoyn_sessionlostreason reason)
-{
- if (sessionId == m_sessionId)
+ if (FAILED(hr))
{
- AllJoynSessionLostEventArgs^ args = ref new AllJoynSessionLostEventArgs(static_cast(reason));
- SessionLost(this, args);
+ throw ref new Exception(hr);
}
-}
-void SecureInterfaceConsumer::OnSessionMemberAdded(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName)
-{
- if (sessionId == m_sessionId)
- {
- auto args = ref new AllJoynSessionMemberAddedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName));
- SessionMemberAdded(this, args);
- }
+ // The consumer needs a bus object to share signals, and its object path must be unique in
+ // case multiple consumers are created using the same bus attachment.
+ Guid gd(result);
+ ServiceObjectPath = gd.ToString();
}
-void SecureInterfaceConsumer::OnSessionMemberRemoved(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName)
+SecureInterfaceConsumer::~SecureInterfaceConsumer()
{
- if (sessionId == m_sessionId)
+ if (nullptr != ProxyBusObject)
{
- auto args = ref new AllJoynSessionMemberRemovedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName));
- SessionMemberRemoved(this, args);
+ alljoyn_proxybusobject_destroy(ProxyBusObject);
}
+ delete m_weak;
}
QStatus SecureInterfaceConsumer::AddSignalHandler(_In_ alljoyn_busattachment busAttachment, _In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_signalhandler_ptr handler)
@@ -94,14 +73,53 @@ QStatus SecureInterfaceConsumer::AddSignalHandler(_In_ alljoyn_busattachment bus
return alljoyn_busattachment_registersignalhandler(busAttachment, handler, member, NULL);
}
-IAsyncOperation^ SecureInterfaceConsumer::JoinSessionAsync(
- _In_ AllJoynServiceInfo^ serviceInfo, _Inout_ SecureInterfaceWatcher^ watcher)
+IAsyncOperation^ SecureInterfaceConsumer::FromIdAsync(_In_ Platform::String^ deviceId)
{
- return create_async([serviceInfo, watcher]() -> SecureInterfaceJoinSessionResult^
+ return SecureInterfaceConsumer::FromIdAsync(deviceId, AllJoynBusAttachment::GetDefault());
+}
+
+IAsyncOperation^ SecureInterfaceConsumer::FromIdAsync(_In_ Platform::String^ deviceId, _In_ AllJoynBusAttachment^ busAttachment)
+{
+ return create_async([deviceId, busAttachment]() -> SecureInterfaceConsumer^
{
- auto result = ref new SecureInterfaceJoinSessionResult();
- result->Consumer = ref new SecureInterfaceConsumer(watcher->BusAttachment);
- result->Status = result->Consumer->JoinSession(serviceInfo);
+ SecureInterfaceConsumer^ result;
+ create_task(AllJoynServiceInfo::FromIdAsync(deviceId)).then([busAttachment, &result](AllJoynServiceInfo^ serviceInfo)
+ {
+ if (serviceInfo != nullptr)
+ {
+ int32 status = AllJoynStatus::Ok;
+ if (busAttachment->State == AllJoynBusAttachmentState::Disconnected)
+ {
+ event connectedEvent;
+ auto token = busAttachment->StateChanged += ref new TypedEventHandler([&connectedEvent](AllJoynBusAttachment^, AllJoynBusAttachmentStateChangedEventArgs^ arg)
+ {
+ if (arg->State == AllJoynBusAttachmentState::Connected)
+ {
+ connectedEvent.set();
+ }
+ });
+
+ status = AllJoynHelpers::CreateInterfaces(busAttachment, c_SecureInterfaceIntrospectionXml);
+ if (status == AllJoynStatus::Ok)
+ {
+ busAttachment->Connect();
+ connectedEvent.wait();
+ }
+ busAttachment->StateChanged -= token;
+ }
+
+ if (status == AllJoynStatus::Ok)
+ {
+ auto consumer = ref new SecureInterfaceConsumer(busAttachment);
+ status = consumer->Initialize(serviceInfo);
+ if (status == AllJoynStatus::Ok)
+ {
+ result = consumer;
+ }
+ }
+ }
+ }).wait();
+
return result;
});
}
@@ -111,24 +129,22 @@ IAsyncOperation^ SecureInterfaceConsumer::Con
return create_async([this, interfaceMemberInStr1, interfaceMemberInStr2]() -> SecureInterfaceConcatenateResult^
{
auto result = ref new SecureInterfaceConcatenateResult();
-
+
alljoyn_message message = alljoyn_message_create(m_nativeBusAttachment);
size_t argCount = 2;
alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount);
QStatus status = ER_OK;
+ status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 0), "s", interfaceMemberInStr1));
if (ER_OK == status)
{
- status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 0), "s", interfaceMemberInStr1));
+ status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 1), "s", interfaceMemberInStr2));
}
-
- status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 1), "s", interfaceMemberInStr2));
-
if (ER_OK == status)
{
status = alljoyn_proxybusobject_methodcall(
ProxyBusObject,
- "com.microsoft.Samples.SecureInterface",
+ m_interfaceName,
"Concatenate",
inputs,
argCount,
@@ -137,7 +153,7 @@ IAsyncOperation^ SecureInterfaceConsumer::Con
0);
}
result->Status = static_cast(status);
- if (ER_OK == status)
+ if (ER_OK == status)
{
result->Status = AllJoynStatus::Ok;
Platform::String^ argument0;
@@ -163,7 +179,7 @@ IAsyncOperation^ SecureInterfaceConsumer::Con
}
result->Status = static_cast(status);
}
-
+
alljoyn_message_destroy(message);
alljoyn_msgarg_destroy(inputs);
@@ -183,7 +199,7 @@ IAsyncOperation^ SecureInterfaceCon
{
status = alljoyn_proxybusobject_setpropertyasync(
ProxyBusObject,
- "com.microsoft.Samples.SecureInterface",
+ m_interfaceName,
"IsUpperCaseEnabled",
inputArgument,
[](QStatus status, alljoyn_proxybusobject obj, void* context)
@@ -213,10 +229,10 @@ IAsyncOperation^ SecureInterfaceCon
return create_async([this]() -> SecureInterfaceGetIsUpperCaseEnabledResult^
{
PropertyGetContext getContext;
-
+
alljoyn_proxybusobject_getpropertyasync(
ProxyBusObject,
- "com.microsoft.Samples.SecureInterface",
+ m_interfaceName,
"IsUpperCaseEnabled",
[](QStatus status, alljoyn_proxybusobject obj, const alljoyn_msgarg value, void* context)
{
@@ -301,39 +317,31 @@ void SecureInterfaceConsumer::CallTextSentSignalHandler(_In_ const alljoyn_inter
}
}
-int32 SecureInterfaceConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo)
+int32 SecureInterfaceConsumer::Initialize(_In_ AllJoynServiceInfo^ serviceInfo)
{
- alljoyn_sessionlistener_callbacks callbacks =
- {
- AllJoynHelpers::SessionLostHandler,
- AllJoynHelpers::SessionMemberAddedHandler,
- AllJoynHelpers::SessionMemberRemovedHandler
- };
-
- alljoyn_busattachment_enableconcurrentcallbacks(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment));
-
- SessionListener = alljoyn_sessionlistener_create(&callbacks, m_weak);
- alljoyn_sessionopts sessionOpts = alljoyn_sessionopts_create(ALLJOYN_TRAFFIC_TYPE_MESSAGES, true, ALLJOYN_PROXIMITY_ANY, ALLJOYN_TRANSPORT_ANY);
-
std::vector sessionNameUtf8 = AllJoynHelpers::PlatformToMultibyteString(serviceInfo->UniqueName);
- RETURN_IF_QSTATUS_ERROR(alljoyn_busattachment_joinsession(
- m_nativeBusAttachment,
- &sessionNameUtf8[0],
- serviceInfo->SessionPort,
- SessionListener,
- &m_sessionId,
- sessionOpts));
- alljoyn_sessionopts_destroy(sessionOpts);
ServiceObjectPath = serviceInfo->ObjectPath;
std::vector objectPath = AllJoynHelpers::PlatformToMultibyteString(ServiceObjectPath);
+ RETURN_IF_QSTATUS_ERROR(AllJoynHelpers::CreateInterfaces(m_busAttachment, c_SecureInterfaceIntrospectionXml));
+
+ m_session = create_task(AllJoynSession::GetFromServiceInfoAsync(serviceInfo, m_busAttachment)).get();
+ if (nullptr == m_session)
+ {
+ return AllJoynStatus::Fail;
+ }
+ else if (m_session->Status != AllJoynStatus::Ok)
+ {
+ return m_session->Status;
+ }
+
if (objectPath.empty())
{
return AllJoynStatus::Fail;
}
- ProxyBusObject = alljoyn_proxybusobject_create(m_nativeBusAttachment, &sessionNameUtf8[0], &objectPath[0], m_sessionId);
+ ProxyBusObject = alljoyn_proxybusobject_create(m_nativeBusAttachment, &sessionNameUtf8[0], &objectPath[0], m_session->Id);
if (nullptr == ProxyBusObject)
{
return AllJoynStatus::Fail;
@@ -343,31 +351,35 @@ int32 SecureInterfaceConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo)
RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_registerpropertieschangedlistener(
ProxyBusObject,
- "com.microsoft.Samples.SecureInterface",
+ m_interfaceName,
propertyNames,
_countof(propertyNames),
- AllJoynHelpers::PropertyChangedHandler,
+ AllJoynHelpers::PropertyChangedHandler,
m_weak));
- alljoyn_interfacedescription description = alljoyn_busattachment_getinterface(m_nativeBusAttachment, "com.microsoft.Samples.SecureInterface");
+ alljoyn_interfacedescription description = alljoyn_busattachment_getinterface(m_nativeBusAttachment, m_interfaceName);
if (nullptr == description)
{
return AllJoynStatus::Fail;
}
- RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::GetBusObject(m_nativeBusAttachment, AllJoynHelpers::PlatformToMultibyteString(ServiceObjectPath).data(), &m_busObject));
-
- if (!AllJoynBusObjectManager::BusObjectIsRegistered(m_nativeBusAttachment, m_busObject))
+ m_busObject = ref new Windows::Devices::AllJoyn::AllJoynBusObject(ServiceObjectPath, m_busAttachment);
+ m_nativeBusObject = AllJoynHelpers::GetInternalBusObject(m_busObject);
+
+ QStatus status = alljoyn_busobject_addinterface(m_nativeBusObject, description);
+ if ((status != ER_OK) && (status != ER_BUS_IFACE_ALREADY_EXISTS))
{
- RETURN_IF_QSTATUS_ERROR(alljoyn_busobject_addinterface(BusObject, description));
+ return status;
}
+
QStatus result = AddSignalHandler(
m_nativeBusAttachment,
description,
"TextSent",
[](const alljoyn_interfacedescription_member* member, PCSTR srcPath, alljoyn_message message) { UNREFERENCED_PARAMETER(srcPath); CallTextSentSignalHandler(member, message); });
+
if (ER_OK != result)
{
return static_cast(result);
@@ -379,7 +391,7 @@ int32 SecureInterfaceConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo)
bool authenticationMechanismsContainsNone = m_busAttachment->AuthenticationMechanisms->IndexOf(AllJoynAuthenticationMechanism::None, &noneMechanismIndex);
QCC_BOOL interfaceIsSecure = alljoyn_interfacedescription_issecure(description);
- // If the current set of AuthenticationMechanisms supports authentication,
+ // If the current set of AuthenticationMechanisms supports authentication,
// determine whether to secure the connection.
if (AllJoynHelpers::CanSecure(m_busAttachment->AuthenticationMechanisms))
{
@@ -388,11 +400,11 @@ int32 SecureInterfaceConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo)
if (!authenticationMechanismsContainsNone || interfaceIsSecure)
{
RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_secureconnection(ProxyBusObject, QCC_FALSE));
- RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, true));
+ m_busObject->Start();
}
else
{
- RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, false));
+ m_busObject->Start();
}
}
else
@@ -405,13 +417,13 @@ int32 SecureInterfaceConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo)
}
else
{
- RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, false));
+ m_busObject->Start();
}
}
RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_addinterface(ProxyBusObject, description));
-
- m_signals->Initialize(BusObject, m_sessionId);
+
+ m_signals->Initialize(this);
return AllJoynStatus::Ok;
}
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.h
index a9be5118d7..50cb866700 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.h
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceConsumer.h
@@ -24,24 +24,30 @@ namespace com { namespace microsoft { namespace Samples { namespace SecureInterf
public interface class ISecureInterfaceConsumer
{
- event Windows::Foundation::TypedEventHandler^ SessionLost;
- event Windows::Foundation::TypedEventHandler^ SessionMemberAdded;
- event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved;
event Windows::Foundation::TypedEventHandler^ IsUpperCaseEnabledChanged;
};
-public ref class SecureInterfaceConsumer sealed : [Windows::Foundation::Metadata::Default] ISecureInterfaceConsumer
+public ref class SecureInterfaceConsumer sealed : [Windows::Foundation::Metadata::Default] ISecureInterfaceConsumer, ISignalEmitter
{
public:
SecureInterfaceConsumer(Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment);
virtual ~SecureInterfaceConsumer();
- // Join the AllJoyn session specified by sessionName.
+ // Create a consumer from a device Id asynchronously.
//
- // This will usually be called after the unique name of a producer has been reported
- // in the Added callback on the Watcher.
- static Windows::Foundation::IAsyncOperation^ JoinSessionAsync(_In_ Windows::Devices::AllJoyn::AllJoynServiceInfo^ serviceInfo, _Inout_ SecureInterfaceWatcher^ watcher);
+ // This is usually called to create a consumer after the unique name of a producer has been reported
+ // in the Added callback on the DeviceWatcher.
+ static Windows::Foundation::IAsyncOperation^ FromIdAsync(_In_ Platform::String^ deviceId);
+ // Create a consumer from a device Id asynchronously with the provided bus attachment.
+ //
+ // This is usually called to create a consumer after the unique name of a producer has been reported
+ // in the Added callback on the DeviceWatcher.
+ static Windows::Foundation::IAsyncOperation^ FromIdAsync(_In_ Platform::String^ deviceId, _In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment);
+
+ int32 SecureInterfaceConsumer::Initialize(_In_ Windows::Devices::AllJoyn::AllJoynServiceInfo^ serviceInfo);
+
+ // "Concatenate two input strings and returns the concatenated string as output"
// Call the Concatenate method
Windows::Foundation::IAsyncOperation^ ConcatenateAsync(_In_ Platform::String^ interfaceMemberInStr1, _In_ Platform::String^ interfaceMemberInStr2);
@@ -66,10 +72,12 @@ public ref class SecureInterfaceConsumer sealed : [Windows::Foundation::Metadat
_IsUpperCaseEnabledChanged(sender, args);
}
}
-
+
+ // "Determine if the output of the Concatenate method is returned as upper case string or not"
// Get the value of the IsUpperCaseEnabled property.
Windows::Foundation::IAsyncOperation^ GetIsUpperCaseEnabledAsync();
+ // "Determine if the output of the Concatenate method is returned as upper case string or not"
// Set the value of the IsUpperCaseEnabled property.
Windows::Foundation::IAsyncOperation^ SetIsUpperCaseEnabledAsync(_In_ bool value);
@@ -79,91 +87,37 @@ public ref class SecureInterfaceConsumer sealed : [Windows::Foundation::Metadat
SecureInterfaceSignals^ get() { return m_signals; }
}
- // This event will fire whenever the consumer loses the session that it is a member of.
- virtual event Windows::Foundation::TypedEventHandler^ SessionLost
- {
- Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler)
- {
- return _SessionLost += ref new Windows::Foundation::EventHandler
- ([handler](Platform::Object^ sender, Platform::Object^ args)
- {
- handler->Invoke(safe_cast(sender), safe_cast(args));
- }, Platform::CallbackContext::Same);
- }
- void remove(Windows::Foundation::EventRegistrationToken token)
- {
- _SessionLost -= token;
- }
- internal:
- void raise(SecureInterfaceConsumer^ sender, Windows::Devices::AllJoyn::AllJoynSessionLostEventArgs^ args)
- {
- _SessionLost(sender, args);
- }
+ // Used to get the name of the interface this consumer implements.
+ static property Platform::String^ InterfaceName
+ {
+ Platform::String^ get() { return AllJoynHelpers::MultibyteToPlatformString(m_interfaceName); }
}
- // This event will fire whenever a member joins the session.
- virtual event Windows::Foundation::TypedEventHandler^ SessionMemberAdded
- {
- Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler)
- {
- return _SessionMemberAdded += ref new Windows::Foundation::EventHandler
- ([handler](Platform::Object^ sender, Platform::Object^ args)
- {
- handler->Invoke(safe_cast(sender), safe_cast(args));
- }, Platform::CallbackContext::Same);
- }
- void remove(Windows::Foundation::EventRegistrationToken token)
- {
- _SessionMemberAdded -= token;
- }
- internal:
- void raise(SecureInterfaceConsumer^ sender, Windows::Devices::AllJoyn::AllJoynSessionMemberAddedEventArgs^ args)
- {
- _SessionMemberAdded(sender, args);
- }
+ virtual property Windows::Devices::AllJoyn::AllJoynBusObject^ BusObject
+ {
+ Windows::Devices::AllJoyn::AllJoynBusObject^ get() { return m_busObject; }
}
- // This event will fire whenever a member leaves the session.
- virtual event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved
- {
- Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler)
- {
- return _SessionMemberRemoved += ref new Windows::Foundation::EventHandler
- ([handler](Platform::Object^ sender, Platform::Object^ args)
- {
- handler->Invoke(safe_cast(sender), safe_cast(args));
- }, Platform::CallbackContext::Same);
- }
- void remove(Windows::Foundation::EventRegistrationToken token)
- {
- _SessionMemberRemoved -= token;
- }
- internal:
- void raise(SecureInterfaceConsumer^ sender, Windows::Devices::AllJoyn::AllJoynSessionMemberRemovedEventArgs^ args)
- {
- _SessionMemberRemoved(sender, args);
- }
+ virtual property Windows::Devices::AllJoyn::AllJoynSession^ Session
+ {
+ Windows::Devices::AllJoyn::AllJoynSession^ get() { return m_session; }
}
internal:
// Consumers do not support property get.
- QStatus OnPropertyGet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _Inout_ alljoyn_msgarg val)
- {
- UNREFERENCED_PARAMETER(interfaceName); UNREFERENCED_PARAMETER(propertyName); UNREFERENCED_PARAMETER(val);
- return ER_NOT_IMPLEMENTED;
+ QStatus OnPropertyGet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _Inout_ alljoyn_msgarg val)
+ {
+ UNREFERENCED_PARAMETER(interfaceName); UNREFERENCED_PARAMETER(propertyName); UNREFERENCED_PARAMETER(val);
+ return ER_NOT_IMPLEMENTED;
}
// Consumers do not support property set.
- QStatus OnPropertySet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg val)
- {
+ QStatus OnPropertySet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg val)
+ {
UNREFERENCED_PARAMETER(interfaceName); UNREFERENCED_PARAMETER(propertyName); UNREFERENCED_PARAMETER(val);
return ER_NOT_IMPLEMENTED;
}
- void OnSessionLost(_In_ alljoyn_sessionid sessionId, _In_ alljoyn_sessionlostreason reason);
- void OnSessionMemberAdded(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName);
- void OnSessionMemberRemoved(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName);
-
void OnPropertyChanged(_In_ alljoyn_proxybusobject obj, _In_ PCSTR interfaceName, _In_ const alljoyn_msgarg changed, _In_ const alljoyn_msgarg invalidated);
property Platform::String^ ServiceObjectPath
@@ -178,44 +132,27 @@ public ref class SecureInterfaceConsumer sealed : [Windows::Foundation::Metadat
void set(alljoyn_proxybusobject value) { m_proxyBusObject = value; }
}
- property alljoyn_busobject BusObject
- {
- alljoyn_busobject get() { return m_busObject; }
- void set(alljoyn_busobject value) { m_busObject = value; }
- }
-
- property alljoyn_sessionlistener SessionListener
- {
- alljoyn_sessionlistener get() { return m_sessionListener; }
- void set(alljoyn_sessionlistener value) { m_sessionListener = value; }
- }
-
- property alljoyn_sessionid SessionId
- {
- alljoyn_sessionid get() { return m_sessionId; }
- }
-
private:
virtual event Windows::Foundation::EventHandler^ _SessionLost;
virtual event Windows::Foundation::EventHandler^ _SessionMemberAdded;
virtual event Windows::Foundation::EventHandler^ _SessionMemberRemoved;
virtual event Windows::Foundation::EventHandler^ _IsUpperCaseEnabledChanged;
- int32 JoinSession(_In_ Windows::Devices::AllJoyn::AllJoynServiceInfo^ serviceInfo);
-
// Register a callback function to handle incoming signals.
QStatus AddSignalHandler(_In_ alljoyn_busattachment busAttachment, _In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_signalhandler_ptr handler);
+ // "This signal is emitted when producer sends a text message to consumer"
static void CallTextSentSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message);
-
+
Windows::Devices::AllJoyn::AllJoynBusAttachment^ m_busAttachment;
+ Windows::Devices::AllJoyn::AllJoynBusObject^ m_busObject;
+ Windows::Devices::AllJoyn::AllJoynSession^ m_session;
SecureInterfaceSignals^ m_signals;
Platform::String^ m_ServiceObjectPath;
alljoyn_proxybusobject m_proxyBusObject;
- alljoyn_busobject m_busObject;
alljoyn_sessionlistener m_sessionListener;
- alljoyn_sessionid m_sessionId;
+ alljoyn_busobject m_nativeBusObject;
alljoyn_busattachment m_nativeBusAttachment;
// Used to pass a pointer to this class to callbacks
@@ -225,6 +162,9 @@ public ref class SecureInterfaceConsumer sealed : [Windows::Foundation::Metadat
// handlers, but the current AllJoyn C API does not allow passing a context to these
// callbacks.
static std::map SourceInterfaces;
+
+ // The name of the interface this consumer implements.
+ static PCSTR m_interfaceName;
};
} } } }
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceEventArgs.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceEventArgs.h
index 7916683af3..5711a7a189 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceEventArgs.h
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceEventArgs.h
@@ -23,6 +23,7 @@
namespace com { namespace microsoft { namespace Samples { namespace SecureInterface {
// Signals
+// "This signal is emitted when producer sends a text message to consumer"
public ref class SecureInterfaceTextSentReceivedEventArgs sealed
{
public:
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceLegacySignals.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceLegacySignals.cpp
new file mode 100644
index 0000000000..5d17129347
--- /dev/null
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceLegacySignals.cpp
@@ -0,0 +1,67 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+//
+//*********************************************************
+//-----------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
+//
+//-----------------------------------------------------------------------------
+#include "pch.h"
+
+using namespace Microsoft::WRL;
+using namespace Platform;
+using namespace Windows::Devices::AllJoyn;
+using namespace Windows::Foundation;
+using namespace com::microsoft::Samples::SecureInterface;
+
+void SecureInterfaceLegacySignals::Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId)
+{
+ m_busObject = busObject;
+ m_sessionId = sessionId;
+
+ auto interfaceDefinition = alljoyn_busattachment_getinterface(alljoyn_busobject_getbusattachment(busObject), "com.microsoft.Samples.SecureInterface");
+ alljoyn_interfacedescription_getmember(interfaceDefinition, "TextSent", &m_memberTextSent);
+}
+
+void SecureInterfaceLegacySignals::TextSent(_In_ Platform::String^ interfaceMemberMessage)
+{
+ if (nullptr == m_busObject)
+ {
+ return;
+ }
+
+ size_t argCount = 1;
+ alljoyn_msgarg arguments = alljoyn_msgarg_array_create(argCount);
+ (void)TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(arguments, 0), "s", interfaceMemberMessage);
+
+ alljoyn_busobject_signal(
+ m_busObject,
+ NULL, // Generated code only supports broadcast signals.
+ m_sessionId,
+ m_memberTextSent,
+ arguments,
+ argCount,
+ 0, // A signal with a TTL of 0 will be sent to every member of the session, regardless of how long it takes to deliver the message
+ ALLJOYN_MESSAGE_FLAG_GLOBAL_BROADCAST, // Broadcast to everyone in the session.
+ NULL); // The generated code does not need the generated signal message
+
+ alljoyn_msgarg_destroy(arguments);
+}
+
+void SecureInterfaceLegacySignals::CallTextSentReceived(_In_ SecureInterfaceLegacySignals^ sender, _In_ SecureInterfaceTextSentReceivedEventArgs^ args)
+{
+ TextSentReceived(sender, args);
+}
+
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceLegacySignals.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceLegacySignals.h
new file mode 100644
index 0000000000..3a8f7aafcf
--- /dev/null
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceLegacySignals.h
@@ -0,0 +1,74 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+//
+//*********************************************************
+//-----------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
+//
+//-----------------------------------------------------------------------------
+#pragma once
+
+namespace com { namespace microsoft { namespace Samples { namespace SecureInterface {
+
+ref class SecureInterfaceLegacySignals;
+
+public interface class ISecureInterfaceLegacySignals
+{
+ event Windows::Foundation::TypedEventHandler^ TextSentReceived;
+};
+
+public ref class SecureInterfaceLegacySignals sealed : [Windows::Foundation::Metadata::Default] ISecureInterfaceLegacySignals
+{
+public:
+ // "This signal is emitted when producer sends a text message to consumer"
+ // Calling this method will send the TextSent signal to every member of the session.
+ void TextSent(_In_ Platform::String^ interfaceMemberMessage);
+
+ // This event fires whenever the TextSent signal is sent by another member of the session.
+ virtual event Windows::Foundation::TypedEventHandler^ TextSentReceived
+ {
+ Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler)
+ {
+ return _TextSentReceived += ref new Windows::Foundation::EventHandler
+ ([handler](Platform::Object^ sender, Platform::Object^ args)
+ {
+ handler->Invoke(safe_cast(sender), safe_cast(args));
+ }, Platform::CallbackContext::Same);
+ }
+ void remove(Windows::Foundation::EventRegistrationToken token)
+ {
+ _TextSentReceived -= token;
+ }
+ internal:
+ void raise(SecureInterfaceLegacySignals^ sender, SecureInterfaceTextSentReceivedEventArgs^ args)
+ {
+ _TextSentReceived(sender, args);
+ }
+ }
+
+internal:
+ void Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId);
+ void CallTextSentReceived(_In_ SecureInterfaceLegacySignals^ sender, _In_ SecureInterfaceTextSentReceivedEventArgs^ args);
+
+private:
+ alljoyn_busobject m_busObject;
+ alljoyn_sessionid m_sessionId;
+
+ virtual event Windows::Foundation::EventHandler^ _TextSentReceived;
+
+ alljoyn_interfacedescription_member m_memberTextSent;
+};
+
+} } } }
\ No newline at end of file
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceMethodResults.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceMethodResults.h
index dd3399d5de..5634f79b49 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceMethodResults.h
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceMethodResults.h
@@ -98,6 +98,7 @@ public ref class SecureInterfaceGetIsUpperCaseEnabledResult sealed
void set(_In_ int32 value) { m_status = value; }
}
+ // "Determine if the output of the Concatenate method is returned as upper case string or not"
property bool IsUpperCaseEnabled
{
bool get() { return m_value; }
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.cpp
index 6c62846f37..2a6078ee6a 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.cpp
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.cpp
@@ -39,7 +39,7 @@ SecureInterfaceProducer::SecureInterfaceProducer(AllJoynBusAttachment^ busAttach
{
m_weak = new WeakReference(this);
ServiceObjectPath = ref new String(L"/Service");
- m_signals = ref new SecureInterfaceSignals();
+ m_signals = ref new SecureInterfaceLegacySignals();
m_busAttachmentStateChangedToken.Value = 0;
}
@@ -444,4 +444,4 @@ PCSTR com::microsoft::Samples::SecureInterface::c_SecureInterfaceIntrospectionXm
" "
" "
""
-;
+;
\ No newline at end of file
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.h
index 6fbdda65d3..bc79c29320 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.h
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceProducer.h
@@ -48,9 +48,9 @@ public ref class SecureInterfaceProducer sealed : [Windows::Foundation::Metadata
}
// Used to send signals or register functions to handle received signals.
- property SecureInterfaceSignals^ Signals
+ property SecureInterfaceLegacySignals^ Signals
{
- SecureInterfaceSignals^ get() { return m_signals; }
+ SecureInterfaceLegacySignals^ get() { return m_signals; }
}
// This event will fire whenever this producer is stopped.
@@ -209,7 +209,9 @@ public ref class SecureInterfaceProducer sealed : [Windows::Foundation::Metadata
virtual event Windows::Foundation::EventHandler^ _SessionMemberAdded;
virtual event Windows::Foundation::EventHandler^ _SessionMemberRemoved;
+ // "Concatenate two input strings and returns the concatenated string as output"
static void CallConcatenateHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message);
+ // "This signal is emitted when producer sends a text message to consumer"
static void CallTextSentSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message);
// Register a callback function to handle methods.
@@ -221,7 +223,7 @@ public ref class SecureInterfaceProducer sealed : [Windows::Foundation::Metadata
Windows::Devices::AllJoyn::AllJoynBusAttachment^ m_busAttachment;
Windows::Foundation::EventRegistrationToken m_busAttachmentStateChangedToken;
- SecureInterfaceSignals^ m_signals;
+ SecureInterfaceLegacySignals^ m_signals;
ISecureInterfaceService^ m_serviceInterface;
Platform::String^ m_ServiceObjectPath;
@@ -241,4 +243,4 @@ public ref class SecureInterfaceProducer sealed : [Windows::Foundation::Metadata
static std::map SourceInterfaces;
};
-} } } }
+} } } }
\ No newline at end of file
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.cpp
index c994e0e9b5..39df1b9014 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.cpp
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.cpp
@@ -9,24 +9,13 @@
//
//*********************************************************
//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// Tool: AllJoynCodeGenerator.exe
+//
+// This code was generated by a tool.
//
-// This tool is located in the Windows 10 SDK and the Windows 10 AllJoyn
-// Visual Studio Extension in the Visual Studio Gallery.
-//
-// The generated code should be packaged in a Windows 10 C++/CX Runtime
-// Component which can be consumed in any UWP-supported language using
-// APIs that are available in Windows.Devices.AllJoyn.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
-// Using AllJoynCodeGenerator - Invoke the following command with a valid
-// Introspection XML file and a writable output directory:
-// AllJoynCodeGenerator -i -o
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
//
//-----------------------------------------------------------------------------
#include "pch.h"
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.h
index 02b0ffe768..1824eb9bff 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.h
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventAdapter.h
@@ -9,24 +9,13 @@
//
//*********************************************************
//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// Tool: AllJoynCodeGenerator.exe
+//
+// This code was generated by a tool.
//
-// This tool is located in the Windows 10 SDK and the Windows 10 AllJoyn
-// Visual Studio Extension in the Visual Studio Gallery.
-//
-// The generated code should be packaged in a Windows 10 C++/CX Runtime
-// Component which can be consumed in any UWP-supported language using
-// APIs that are available in Windows.Devices.AllJoyn.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
-// Using AllJoynCodeGenerator - Invoke the following command with a valid
-// Introspection XML file and a writable output directory:
-// AllJoynCodeGenerator -i -o
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
//
//-----------------------------------------------------------------------------
#pragma once
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.cpp
index 2d384de757..19021f61df 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.cpp
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.cpp
@@ -9,24 +9,13 @@
//
//*********************************************************
//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// Tool: AllJoynCodeGenerator.exe
+//
+// This code was generated by a tool.
//
-// This tool is located in the Windows 10 SDK and the Windows 10 AllJoyn
-// Visual Studio Extension in the Visual Studio Gallery.
-//
-// The generated code should be packaged in a Windows 10 C++/CX Runtime
-// Component which can be consumed in any UWP-supported language using
-// APIs that are available in Windows.Devices.AllJoyn.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
-// Using AllJoynCodeGenerator - Invoke the following command with a valid
-// Introspection XML file and a writable output directory:
-// AllJoynCodeGenerator -i -o
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
//
//-----------------------------------------------------------------------------
#include "pch.h"
@@ -51,7 +40,7 @@ SecureInterfaceConcatenateCalledEventArgs::SecureInterfaceConcatenateCalledEvent
m_interfaceMemberInStr1(interfaceMemberInStr1),
m_interfaceMemberInStr2(interfaceMemberInStr2)
{
- m_result = SecureInterfaceConcatenateResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
+ m_result = SecureInterfaceConcatenateResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
}
Deferral^ SecureInterfaceConcatenateCalledEventArgs::GetDeferral()
@@ -127,7 +116,7 @@ SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs::SecureInterfaceGetIsUppe
m_completionsRequired(0),
m_messageInfo(info)
{
- m_result = SecureInterfaceGetIsUpperCaseEnabledResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
+ m_result = SecureInterfaceGetIsUpperCaseEnabledResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
}
Deferral^ SecureInterfaceGetIsUpperCaseEnabledRequestedEventArgs::GetDeferral()
@@ -205,7 +194,7 @@ SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs::SecureInterfaceSetIsUppe
m_messageInfo(info),
m_value(value)
{
- m_result = SecureInterfaceSetIsUpperCaseEnabledResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
+ m_result = SecureInterfaceSetIsUpperCaseEnabledResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
}
Deferral^ SecureInterfaceSetIsUpperCaseEnabledRequestedEventArgs::GetDeferral()
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.h
index 82476f6f47..68e0f0f19e 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.h
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceServiceEventArgs.h
@@ -9,24 +9,13 @@
//
//*********************************************************
//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// Tool: AllJoynCodeGenerator.exe
+//
+// This code was generated by a tool.
//
-// This tool is located in the Windows 10 SDK and the Windows 10 AllJoyn
-// Visual Studio Extension in the Visual Studio Gallery.
-//
-// The generated code should be packaged in a Windows 10 C++/CX Runtime
-// Component which can be consumed in any UWP-supported language using
-// APIs that are available in Windows.Devices.AllJoyn.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
-// Using AllJoynCodeGenerator - Invoke the following command with a valid
-// Introspection XML file and a writable output directory:
-// AllJoynCodeGenerator -i -o
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
//
//-----------------------------------------------------------------------------
#pragma once
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.cpp
index 04959ba630..7663d85e25 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.cpp
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.cpp
@@ -26,18 +26,17 @@ using namespace Windows::Devices::AllJoyn;
using namespace Windows::Foundation;
using namespace com::microsoft::Samples::SecureInterface;
-void SecureInterfaceSignals::Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId)
+void SecureInterfaceSignals::Initialize(_In_ ISignalEmitter^ emitter)
{
- m_busObject = busObject;
- m_sessionId = sessionId;
-
- auto interfaceDefinition = alljoyn_busattachment_getinterface(alljoyn_busobject_getbusattachment(busObject), "com.microsoft.Samples.SecureInterface");
+ m_emitter = emitter;
+ alljoyn_busattachment nativeBusAttachment = AllJoynHelpers::GetInternalBusAttachment(m_emitter->BusObject->BusAttachment);
+ auto interfaceDefinition = alljoyn_busattachment_getinterface(nativeBusAttachment, "com.microsoft.Samples.SecureInterface");
alljoyn_interfacedescription_getmember(interfaceDefinition, "TextSent", &m_memberTextSent);
}
void SecureInterfaceSignals::TextSent(_In_ Platform::String^ interfaceMemberMessage)
{
- if (nullptr == m_busObject)
+ if (nullptr == AllJoynHelpers::GetInternalBusObject(m_emitter->BusObject))
{
return;
}
@@ -47,9 +46,9 @@ void SecureInterfaceSignals::TextSent(_In_ Platform::String^ interfaceMemberMess
(void)TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(arguments, 0), "s", interfaceMemberMessage);
alljoyn_busobject_signal(
- m_busObject,
+ AllJoynHelpers::GetInternalBusObject(m_emitter->BusObject),
NULL, // Generated code only supports broadcast signals.
- m_sessionId,
+ m_emitter->Session->Id,
m_memberTextSent,
arguments,
argCount,
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.h
index 85bb579e67..d3fd1adb00 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.h
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceSignals.h
@@ -32,6 +32,7 @@ public interface class ISecureInterfaceSignals
public ref class SecureInterfaceSignals sealed : [Windows::Foundation::Metadata::Default] ISecureInterfaceSignals
{
public:
+ // "This signal is emitted when producer sends a text message to consumer"
// Calling this method will send the TextSent signal to every member of the session.
void TextSent(_In_ Platform::String^ interfaceMemberMessage);
@@ -58,12 +59,11 @@ public ref class SecureInterfaceSignals sealed : [Windows::Foundation::Metadata:
}
internal:
- void Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId);
+ void Initialize(_In_ ISignalEmitter^ emitter);
void CallTextSentReceived(_In_ SecureInterfaceSignals^ sender, _In_ SecureInterfaceTextSentReceivedEventArgs^ args);
private:
- alljoyn_busobject m_busObject;
- alljoyn_sessionid m_sessionId;
+ ISignalEmitter^ m_emitter;
virtual event Windows::Foundation::EventHandler^ _TextSentReceived;
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceWatcher.cpp b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceWatcher.cpp
deleted file mode 100644
index 60f2763d63..0000000000
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceWatcher.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-//*********************************************************
-//
-// Copyright (c) Microsoft. All rights reserved.
-// This code is licensed under the MIT License (MIT).
-// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
-// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
-// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
-// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
-//
-//*********************************************************
-//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
-//
-//-----------------------------------------------------------------------------
-#include "pch.h"
-
-using namespace concurrency;
-using namespace Microsoft::WRL;
-using namespace Platform;
-using namespace Windows::Foundation;
-using namespace Windows::Devices::AllJoyn;
-using namespace com::microsoft::Samples::SecureInterface;
-
-SecureInterfaceWatcher::SecureInterfaceWatcher(AllJoynBusAttachment^ busAttachment) :
- m_aboutListener(nullptr)
-{
- m_busAttachment = busAttachment;
- m_weak = new WeakReference(this);
- m_busAttachmentStateChangedToken.Value = 0;
-}
-
-SecureInterfaceWatcher::~SecureInterfaceWatcher()
-{
- UnregisterFromBus();
-}
-
-void SecureInterfaceWatcher::UnregisterFromBus()
-{
- if (nullptr != m_aboutListener)
- {
- PCSTR interfaces[] = { "com.microsoft.Samples.SecureInterface" };
- alljoyn_busattachment_cancelwhoimplements_interfaces(
- AllJoynHelpers::GetInternalBusAttachment(m_busAttachment),
- interfaces,
- _countof(interfaces));
-
- alljoyn_busattachment_unregisteraboutlistener(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), m_aboutListener);
- alljoyn_aboutlistener_destroy(m_aboutListener);
- m_aboutListener = nullptr;
- }
- if ((nullptr != m_busAttachment) && (0 != m_busAttachmentStateChangedToken.Value))
- {
- m_busAttachment->StateChanged -= m_busAttachmentStateChangedToken;
- }
-}
-
-void SecureInterfaceWatcher::OnAnnounce(
- _In_ PCSTR name,
- _In_ uint16_t version,
- _In_ alljoyn_sessionport port,
- _In_ alljoyn_msgarg objectDescriptionArg,
- _In_ const alljoyn_msgarg aboutDataArg)
-{
- UNREFERENCED_PARAMETER(version);
- UNREFERENCED_PARAMETER(aboutDataArg);
-
- alljoyn_aboutobjectdescription objectDescription = alljoyn_aboutobjectdescription_create_full(objectDescriptionArg);
-
- if (alljoyn_aboutobjectdescription_hasinterface(objectDescription, "com.microsoft.Samples.SecureInterface"))
- {
- AllJoynServiceInfo^ args = ref new AllJoynServiceInfo(
- AllJoynHelpers::MultibyteToPlatformString(name),
- AllJoynHelpers::GetObjectPath(objectDescription, "com.microsoft.Samples.SecureInterface"),
- port);
- Added(this, args);
- }
- alljoyn_aboutobjectdescription_destroy(objectDescription);
-}
-
-void SecureInterfaceWatcher::BusAttachmentStateChanged(_In_ AllJoynBusAttachment^ sender, _In_ AllJoynBusAttachmentStateChangedEventArgs^ args)
-{
- if (args->State == AllJoynBusAttachmentState::Connected)
- {
- alljoyn_aboutlistener_callback callbacks =
- {
- AllJoynHelpers::AnnounceHandler
- };
- m_aboutListener = alljoyn_aboutlistener_create(&callbacks, m_weak);
-
- alljoyn_busattachment_registeraboutlistener(AllJoynHelpers::GetInternalBusAttachment(sender), m_aboutListener);
- PCSTR interfaces[] = { "com.microsoft.Samples.SecureInterface" };
-
- auto status = alljoyn_busattachment_whoimplements_interfaces(
- AllJoynHelpers::GetInternalBusAttachment(sender),
- interfaces,
- _countof(interfaces));
- if (ER_OK != status)
- {
- StopInternal(status);
- }
- }
- else if (args->State == AllJoynBusAttachmentState::Disconnected)
- {
- StopInternal(ER_BUS_STOPPING);
- }
-}
-
-void SecureInterfaceWatcher::Start()
-{
- if (nullptr == m_busAttachment)
- {
- StopInternal(ER_FAIL);
- return;
- }
-
- int32 result = AllJoynHelpers::CreateInterfaces(m_busAttachment, c_SecureInterfaceIntrospectionXml);
- if (result != AllJoynStatus::Ok)
- {
- StopInternal(result);
- return;
- }
-
- m_busAttachmentStateChangedToken = m_busAttachment->StateChanged += ref new TypedEventHandler(this, &SecureInterfaceWatcher::BusAttachmentStateChanged);
- m_busAttachment->Connect();
-}
-
-void SecureInterfaceWatcher::Stop()
-{
- StopInternal(AllJoynStatus::Ok);
-}
-
-void SecureInterfaceWatcher::StopInternal(int32 status)
-{
- UnregisterFromBus();
- Stopped(this, ref new AllJoynProducerStoppedEventArgs(status));
-}
\ No newline at end of file
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceWatcher.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceWatcher.h
deleted file mode 100644
index 97ba78d8b0..0000000000
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/SecureInterfaceWatcher.h
+++ /dev/null
@@ -1,127 +0,0 @@
-//*********************************************************
-//
-// Copyright (c) Microsoft. All rights reserved.
-// This code is licensed under the MIT License (MIT).
-// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
-// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
-// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
-// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
-//
-//*********************************************************
-//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
-//
-//-----------------------------------------------------------------------------
-#pragma once
-
-namespace com { namespace microsoft { namespace Samples { namespace SecureInterface {
-
-ref class SecureInterfaceWatcher;
-
-public interface class ISecureInterfaceWatcher
-{
- event Windows::Foundation::TypedEventHandler^ Added;
- event Windows::Foundation::TypedEventHandler^ Stopped;
-};
-
-public ref class SecureInterfaceWatcher sealed : [Windows::Foundation::Metadata::Default] ISecureInterfaceWatcher
-{
-public:
- SecureInterfaceWatcher(Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment);
- virtual ~SecureInterfaceWatcher();
-
- // This event will fire whenever a producer for this service is found.
- virtual event Windows::Foundation::TypedEventHandler^ Added
- {
- Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler)
- {
- return _Added += ref new Windows::Foundation::EventHandler
- ([handler](Platform::Object^ sender, Platform::Object^ args)
- {
- handler->Invoke(safe_cast(sender), safe_cast(args));
- }, Platform::CallbackContext::Same);
- }
- void remove(Windows::Foundation::EventRegistrationToken token)
- {
- _Added -= token;
- }
- internal:
- void raise(SecureInterfaceWatcher^ sender, Windows::Devices::AllJoyn::AllJoynServiceInfo^ args)
- {
- _Added(sender, args);
- }
- }
-
- // This event will fire whenever the watcher is stopped.
- virtual event Windows::Foundation::TypedEventHandler^ Stopped
- {
- Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler)
- {
- return _Stopped += ref new Windows::Foundation::EventHandler
- ([handler](Platform::Object^ sender, Platform::Object^ args)
- {
- handler->Invoke(safe_cast(sender), safe_cast(args));
- }, Platform::CallbackContext::Same);
- }
- void remove(Windows::Foundation::EventRegistrationToken token)
- {
- _Stopped -= token;
- }
- internal:
- void raise(SecureInterfaceWatcher^ sender, Windows::Devices::AllJoyn::AllJoynProducerStoppedEventArgs^ args)
- {
- _Stopped(sender, args);
- }
- }
-
- // Start watching for producers advertising this service.
- void Start();
-
- // Stop watching for producers for this service.
- void Stop();
-
-internal:
- void OnAnnounce(
- _In_ PCSTR name,
- _In_ uint16_t version,
- _In_ alljoyn_sessionport port,
- _In_ alljoyn_msgarg objectDescriptionArg,
- _In_ const alljoyn_msgarg aboutDataArg);
-
- void OnPropertyChanged(_In_ PCSTR prop_name, _In_ alljoyn_msgarg prop_value)
- {
- UNREFERENCED_PARAMETER(prop_name); UNREFERENCED_PARAMETER(prop_value);
- }
-
- property Windows::Devices::AllJoyn::AllJoynBusAttachment^ BusAttachment
- {
- Windows::Devices::AllJoyn::AllJoynBusAttachment^ get() { return m_busAttachment; }
- }
-
- // Stop watching for producers advertising this service and pass status to anyone listening for the Stopped event.
- void StopInternal(int32 status);
-
- void BusAttachmentStateChanged(_In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ sender, _In_ Windows::Devices::AllJoyn::AllJoynBusAttachmentStateChangedEventArgs^ args);
-
-private:
- virtual event Windows::Foundation::EventHandler^ _Added;
- virtual event Windows::Foundation::EventHandler^ _Stopped;
-
- void UnregisterFromBus();
-
- Windows::Devices::AllJoyn::AllJoynBusAttachment^ m_busAttachment;
- Windows::Foundation::EventRegistrationToken m_busAttachmentStateChangedToken;
-
- alljoyn_aboutlistener m_aboutListener;
-
- // Used to pass a pointer to this class to callbacks.
- Platform::WeakReference* m_weak;
-};
-
-} } } }
\ No newline at end of file
diff --git a/Samples/AllJoyn/Common/Scenario1WinRTComponent/pch.h b/Samples/AllJoyn/Common/Scenario1WinRTComponent/pch.h
index d75dfddc21..74ad51f3b1 100644
--- a/Samples/AllJoyn/Common/Scenario1WinRTComponent/pch.h
+++ b/Samples/AllJoyn/Common/Scenario1WinRTComponent/pch.h
@@ -45,8 +45,8 @@
#include "SecureInterfaceEventArgs.h"
#include "ISecureInterfaceService.h"
#include "SecureInterfaceSignals.h"
+#include "SecureInterfaceLegacySignals.h"
#include "SecureInterfaceProducer.h"
-#include "SecureInterfaceWatcher.h"
#include "SecureInterfaceConsumer.h"
#include "SecureInterfaceServiceEventArgs.h"
#include "SecureInterfaceServiceEventAdapter.h"
\ No newline at end of file
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/AllJoynHelpers.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/AllJoynHelpers.h
new file mode 100644
index 0000000000..1987e10a79
--- /dev/null
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/AllJoynHelpers.h
@@ -0,0 +1,277 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+//
+//*********************************************************
+//-----------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
+//
+//-----------------------------------------------------------------------------
+#pragma once
+
+// The amount of time to wait (ms) for a response after sending a message before timing out.
+const int c_MessageTimeoutInMilliseconds = 10000;
+
+// The maximum length of an AllJoyn type signature allowed by the AllJoyn Core library.
+const int c_MaximumSignatureLength = 255;
+
+#define RETURN_IF_QSTATUS_ERROR(status) \
+{ \
+int32 alljoynStatus = static_cast(status); \
+if (Windows::Devices::AllJoyn::AllJoynStatus::Ok != alljoynStatus) \
+{ \
+ return status; \
+} \
+}
+
+namespace org { namespace alljoyn { namespace Onboarding {
+
+public interface class ISignalEmitter
+{
+ property Windows::Devices::AllJoyn::AllJoynBusObject^ BusObject
+ {
+ Windows::Devices::AllJoyn::AllJoynBusObject^ get();
+ }
+
+ property Windows::Devices::AllJoyn::AllJoynSession^ Session
+ {
+ Windows::Devices::AllJoyn::AllJoynSession^ get();
+ }
+};
+
+} } }
+
+class AllJoynHelpers
+{
+public:
+ // The Windows::Devices::AllJoyn::AllJoynBusAttachment class wraps the alljoyn_busattachment type. This
+ // function gets the underlying alljoyn_busattachment.
+ static alljoyn_busattachment GetInternalBusAttachment(_In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment);
+
+ // The Windows::Devices::AllJoyn::AllJoynBusObject class wraps the alljoyn_busobject type. This
+ // function gets the underlying alljoyn_busobject.
+ static alljoyn_busobject AllJoynHelpers::GetInternalBusObject(_In_ Windows::Devices::AllJoyn::AllJoynBusObject^ busObject);
+
+ // Create the alljoyn_interfacedescriptions described in introspectionXml and add them to the busAttachment.
+ static QStatus CreateInterfaces(_Inout_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment, _In_ PCSTR introspectionXml);
+
+ // Convert a UTF8 string to a wide character Platform::String.
+ static Platform::String^ MultibyteToPlatformString(_In_ PCSTR);
+
+ // Convert a wide character Platform::String to a UTF8 string.
+ static std::vector PlatformToMultibyteString(_In_ Platform::String^ str);
+
+ // Get the service object path from an objectDescriptionArg. The objectDescriptionArg should
+ // come from an Announce signal.
+ static Platform::String^ GetObjectPath(_In_ alljoyn_aboutobjectdescription objectDescription, _In_ PCSTR interfaceName);
+
+ // Determine whether the supplied set of AuthenticationMechanisms is sufficient for securing an AllJoyn connection.
+ static bool CanSecure(_In_ Windows::Foundation::Collections::IVector^ authenticationMechanisms);
+
+ // Callback for alljoyn_proxybusobject_listener_propertieschanged_ptr.
+ // This callback expects the context to be of type T, which must implement the OnPropertyChanged function.
+ template
+ static void AJ_CALL PropertyChangedHandler(_In_ alljoyn_proxybusobject obj, _In_ PCSTR interfaceName, _In_ const alljoyn_msgarg changed, _In_ const alljoyn_msgarg invalidated, _In_ void* context)
+ {
+ T^ caller = static_cast(context)->Resolve();
+ caller->OnPropertyChanged(obj, interfaceName, changed, invalidated);
+ }
+
+ // Callback for alljoyn_busobject_prop_get_ptr.
+ template
+ static QStatus AJ_CALL PropertyGetHandler(_In_ const void* context, _In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg value)
+ {
+ T^ caller = static_cast(context)->Resolve();
+ return caller->OnPropertyGet(interfaceName, propertyName, value);
+ }
+
+ // Callback for alljoyn_busobject_prop_set_ptr.
+ template
+ static QStatus AJ_CALL PropertySetHandler(_In_ const void* context, _In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg value)
+ {
+ T^ caller = static_cast(context)->Resolve();
+ return caller->OnPropertySet(interfaceName, propertyName, value);
+ }
+
+ // Callback for alljoyn_sessionlistener_sessionlost_ptr.
+ template
+ static void AJ_CALL SessionLostHandler(_In_ const void* context, _In_ alljoyn_sessionid sessionId, _In_ alljoyn_sessionlostreason reason)
+ {
+ T^ caller = static_cast(context)->Resolve();
+ caller->OnSessionLost(sessionId, reason);
+ }
+
+ // Callback for alljoyn_sessionlistener_sessionmemberadded_ptr.
+ template
+ static void AJ_CALL SessionMemberAddedHandler(_In_ const void* context, _In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName)
+ {
+ T^ caller = static_cast(context)->Resolve();
+ caller->OnSessionMemberAdded(sessionId, uniqueName);
+ }
+
+ // Callback for alljoyn_sessionlistener_sessionmemberremoved_ptr.
+ template
+ static void AJ_CALL SessionMemberRemovedHandler(_In_ const void* context, _In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName)
+ {
+ T^ caller = static_cast(context)->Resolve();
+ caller->OnSessionMemberRemoved(sessionId, uniqueName);
+ }
+
+ // Create an AllJoyn bus object.
+ template
+ static QStatus CreateBusObject(_Inout_ Platform::WeakReference* target)
+ {
+ alljoyn_busobject_callbacks callbacks =
+ {
+ PropertyGetHandler,
+ PropertySetHandler,
+ nullptr,
+ nullptr,
+ };
+
+ T^ caller = target->Resolve();
+
+ auto serviceObjectPath = PlatformToMultibyteString(caller->ServiceObjectPath);
+ alljoyn_busobject busObject = alljoyn_busobject_create(serviceObjectPath.data(), false, &callbacks, target);
+ if (busObject == nullptr)
+ {
+ return ER_FAIL;
+ }
+
+ caller->BusObject = busObject;
+
+ return ER_OK;
+ }
+
+ // Callback for alljoyn_sessionportlistener_acceptsessionjoiner_ptr.
+ // This callback expects the context to be of type T, which must implement the OnAcceptSessionJoiner function.
+ template
+ static QCC_BOOL AJ_CALL AcceptSessionJoinerHandler(
+ _In_ const void* context,
+ _In_ alljoyn_sessionport sessionPort,
+ _In_ PCSTR joiner,
+ _In_ const alljoyn_sessionopts opts)
+ {
+ T^ caller = static_cast(context)->Resolve();
+ return caller->OnAcceptSessionJoiner(sessionPort, joiner, opts);
+ }
+
+ // Callback for alljoyn_sessionportlistener_sessionjoined_ptr.
+ // This callback expects the context to be of type T, which must implement the OnSessionJoined function.
+ template
+ static void AJ_CALL SessionJoinedHandler(
+ _In_ const void* context,
+ _In_ alljoyn_sessionport sessionPort,
+ _In_ alljoyn_sessionid id,
+ _In_ PCSTR joiner)
+ {
+ T^ caller = static_cast(context)->Resolve();
+ caller->OnSessionJoined(sessionPort, id, joiner);
+ }
+
+ // Create the session for an AllJoyn producer.
+ template
+ static QStatus CreateProducerSession(_Inout_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment, _Inout_ Platform::WeakReference* target)
+ {
+ alljoyn_sessionopts opts = alljoyn_sessionopts_create(ALLJOYN_TRAFFIC_TYPE_MESSAGES, true, ALLJOYN_PROXIMITY_ANY, ALLJOYN_TRANSPORT_ANY);
+
+ alljoyn_sessionportlistener_callbacks callbacks =
+ {
+ AcceptSessionJoinerHandler,
+ SessionJoinedHandler
+ };
+
+ T^ producer = target->Resolve();
+ producer->SessionPortListener = alljoyn_sessionportlistener_create(&callbacks, target);
+
+ alljoyn_sessionport sessionPort = 42;
+ alljoyn_busattachment_unbindsessionport(AllJoynHelpers::GetInternalBusAttachment(busAttachment), sessionPort);
+ RETURN_IF_QSTATUS_ERROR(alljoyn_busattachment_bindsessionport(AllJoynHelpers::GetInternalBusAttachment(busAttachment), &sessionPort, opts, producer->SessionPortListener));
+ producer->SessionPort = sessionPort;
+
+ alljoyn_sessionopts_destroy(opts);
+
+ return ER_OK;
+ }
+};
+
+// Passed to property get callbacks to allow them to report when the async operation is completed.
+template
+class PropertyGetContext
+{
+public:
+ void SetEvent()
+ {
+ m_event.set();
+ }
+
+ void Wait()
+ {
+ m_event.wait();
+ }
+
+ QStatus GetStatus()
+ {
+ return m_status;
+ }
+
+ void SetStatus(QStatus value)
+ {
+ m_status = value;
+ }
+
+ T GetValue()
+ {
+ return m_value;
+ }
+
+ void SetValue(T value)
+ {
+ m_value = value;
+ }
+
+private:
+ Concurrency::event m_event;
+ QStatus m_status;
+ T m_value;
+};
+
+// Passed to property set callbacks to allow them to report when the async operation is completed.
+class PropertySetContext
+{
+public:
+ void SetEvent()
+ {
+ m_event.set();
+ }
+
+ void Wait()
+ {
+ m_event.wait();
+ }
+
+ QStatus GetStatus()
+ {
+ return m_status;
+ }
+
+ void SetStatus(QStatus value)
+ {
+ m_status = value;
+ }
+
+private:
+ Concurrency::event m_event;
+ QStatus m_status;
+};
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/IOnboardingService.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/IOnboardingService.h
index ab25d032de..65ba47eb2c 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/IOnboardingService.h
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/IOnboardingService.h
@@ -25,28 +25,35 @@ namespace org { namespace alljoyn { namespace Onboarding {
public interface class IOnboardingService
{
public:
+ // "Sends the personal AP information to the onboardee"
// Implement this function to handle calls to the ConfigureWiFi method.
Windows::Foundation::IAsyncOperation^ ConfigureWiFiAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info , _In_ Platform::String^ interfaceMemberSSID, _In_ Platform::String^ interfaceMemberPassphrase, _In_ int16 interfaceMemberAuthType);
+ // "Tells the onboardee to connect to the personal AP"
// Implement this function to handle calls to the Connect method.
Windows::Foundation::IAsyncOperation^ ConnectAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info );
+ // "Tells the onboardee to disconnect from the personal AP"
// Implement this function to handle calls to the Offboard method.
Windows::Foundation::IAsyncOperation^ OffboardAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info );
+ // "Scans all the Wi-Fi access points in the onboardee's proximity"
// Implement this function to handle calls to the GetScanInfo method.
Windows::Foundation::IAsyncOperation^ GetScanInfoAsync(_In_ Windows::Devices::AllJoyn::AllJoynMessageInfo^ info );
+ // "Interface version number"
// Implement this function to handle requests for the value of the Version property.
//
// Currently, info will always be null, because no information is available about the requestor.
Windows::Foundation::IAsyncOperation^ GetVersionAsync(Windows::Devices::AllJoyn::AllJoynMessageInfo^ info);
+ // "The configuration state"
// Implement this function to handle requests for the value of the State property.
//
// Currently, info will always be null, because no information is available about the requestor.
Windows::Foundation::IAsyncOperation^ GetStateAsync(Windows::Devices::AllJoyn::AllJoynMessageInfo^ info);
+ // "The last error code and error message"
// Implement this function to handle requests for the value of the LastError property.
//
// Currently, info will always be null, because no information is available about the requestor.
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.cpp
index 746bbf8a87..783f0f682b 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.cpp
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.cpp
@@ -28,59 +28,38 @@ using namespace Windows::Devices::AllJoyn;
using namespace org::alljoyn::Onboarding;
std::map OnboardingConsumer::SourceInterfaces;
+PCSTR OnboardingConsumer::m_interfaceName = "org.alljoyn.Onboarding";
OnboardingConsumer::OnboardingConsumer(AllJoynBusAttachment^ busAttachment)
: m_busAttachment(busAttachment),
m_proxyBusObject(nullptr),
- m_busObject(nullptr),
- m_sessionListener(nullptr),
- m_sessionId(0)
+ m_busObject(nullptr)
{
m_weak = new WeakReference(this);
m_signals = ref new OnboardingSignals();
m_nativeBusAttachment = AllJoynHelpers::GetInternalBusAttachment(m_busAttachment);
-}
-OnboardingConsumer::~OnboardingConsumer()
-{
- AllJoynBusObjectManager::ReleaseBusObject(m_nativeBusAttachment, AllJoynHelpers::PlatformToMultibyteString(ServiceObjectPath).data());
- if (SessionListener != nullptr)
- {
- alljoyn_busattachment_setsessionlistener(m_nativeBusAttachment, m_sessionId, nullptr);
- alljoyn_sessionlistener_destroy(SessionListener);
- }
- if (nullptr != ProxyBusObject)
- {
- alljoyn_proxybusobject_destroy(ProxyBusObject);
- }
- delete m_weak;
-}
+ GUID result;
+ HRESULT hr = CoCreateGuid(&result);
-void OnboardingConsumer::OnSessionLost(_In_ alljoyn_sessionid sessionId, _In_ alljoyn_sessionlostreason reason)
-{
- if (sessionId == m_sessionId)
+ if (FAILED(hr))
{
- AllJoynSessionLostEventArgs^ args = ref new AllJoynSessionLostEventArgs(static_cast(reason));
- SessionLost(this, args);
+ throw ref new Exception(hr);
}
-}
-void OnboardingConsumer::OnSessionMemberAdded(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName)
-{
- if (sessionId == m_sessionId)
- {
- auto args = ref new AllJoynSessionMemberAddedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName));
- SessionMemberAdded(this, args);
- }
+ // The consumer needs a bus object to share signals, and its object path must be unique in
+ // case multiple consumers are created using the same bus attachment.
+ Guid gd(result);
+ ServiceObjectPath = gd.ToString();
}
-void OnboardingConsumer::OnSessionMemberRemoved(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName)
+OnboardingConsumer::~OnboardingConsumer()
{
- if (sessionId == m_sessionId)
+ if (nullptr != ProxyBusObject)
{
- auto args = ref new AllJoynSessionMemberRemovedEventArgs(AllJoynHelpers::MultibyteToPlatformString(uniqueName));
- SessionMemberRemoved(this, args);
+ alljoyn_proxybusobject_destroy(ProxyBusObject);
}
+ delete m_weak;
}
QStatus OnboardingConsumer::AddSignalHandler(_In_ alljoyn_busattachment busAttachment, _In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_signalhandler_ptr handler)
@@ -94,14 +73,53 @@ QStatus OnboardingConsumer::AddSignalHandler(_In_ alljoyn_busattachment busAttac
return alljoyn_busattachment_registersignalhandler(busAttachment, handler, member, NULL);
}
-IAsyncOperation^ OnboardingConsumer::JoinSessionAsync(
- _In_ AllJoynServiceInfo^ serviceInfo, _Inout_ OnboardingWatcher^ watcher)
+IAsyncOperation^ OnboardingConsumer::FromIdAsync(_In_ Platform::String^ deviceId)
{
- return create_async([serviceInfo, watcher]() -> OnboardingJoinSessionResult^
+ return OnboardingConsumer::FromIdAsync(deviceId, AllJoynBusAttachment::GetDefault());
+}
+
+IAsyncOperation^ OnboardingConsumer::FromIdAsync(_In_ Platform::String^ deviceId, _In_ AllJoynBusAttachment^ busAttachment)
+{
+ return create_async([deviceId, busAttachment]() -> OnboardingConsumer^
{
- auto result = ref new OnboardingJoinSessionResult();
- result->Consumer = ref new OnboardingConsumer(watcher->BusAttachment);
- result->Status = result->Consumer->JoinSession(serviceInfo);
+ OnboardingConsumer^ result;
+ create_task(AllJoynServiceInfo::FromIdAsync(deviceId)).then([busAttachment, &result](AllJoynServiceInfo^ serviceInfo)
+ {
+ if (serviceInfo != nullptr)
+ {
+ int32 status = AllJoynStatus::Ok;
+ if (busAttachment->State == AllJoynBusAttachmentState::Disconnected)
+ {
+ event connectedEvent;
+ auto token = busAttachment->StateChanged += ref new TypedEventHandler([&connectedEvent](AllJoynBusAttachment^, AllJoynBusAttachmentStateChangedEventArgs^ arg)
+ {
+ if (arg->State == AllJoynBusAttachmentState::Connected)
+ {
+ connectedEvent.set();
+ }
+ });
+
+ status = AllJoynHelpers::CreateInterfaces(busAttachment, c_OnboardingIntrospectionXml);
+ if (status == AllJoynStatus::Ok)
+ {
+ busAttachment->Connect();
+ connectedEvent.wait();
+ }
+ busAttachment->StateChanged -= token;
+ }
+
+ if (status == AllJoynStatus::Ok)
+ {
+ auto consumer = ref new OnboardingConsumer(busAttachment);
+ status = consumer->Initialize(serviceInfo);
+ if (status == AllJoynStatus::Ok)
+ {
+ result = consumer;
+ }
+ }
+ }
+ }).wait();
+
return result;
});
}
@@ -111,26 +129,26 @@ IAsyncOperation^ OnboardingConsumer::ConfigureWi
return create_async([this, interfaceMemberSSID, interfaceMemberPassphrase, interfaceMemberAuthType]() -> OnboardingConfigureWiFiResult^
{
auto result = ref new OnboardingConfigureWiFiResult();
-
+
alljoyn_message message = alljoyn_message_create(m_nativeBusAttachment);
size_t argCount = 3;
alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount);
QStatus status = ER_OK;
+ status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 0), "s", interfaceMemberSSID));
+ if (ER_OK == status)
+ {
+ status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 1), "s", interfaceMemberPassphrase));
+ }
if (ER_OK == status)
{
- status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 0), "s", interfaceMemberSSID));
+ status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 2), "n", interfaceMemberAuthType));
}
-
- status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 1), "s", interfaceMemberPassphrase));
-
- status = static_cast(TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(inputs, 2), "n", interfaceMemberAuthType));
-
if (ER_OK == status)
{
status = alljoyn_proxybusobject_methodcall(
ProxyBusObject,
- "org.alljoyn.Onboarding",
+ m_interfaceName,
"ConfigureWiFi",
inputs,
argCount,
@@ -139,7 +157,7 @@ IAsyncOperation^ OnboardingConsumer::ConfigureWi
0);
}
result->Status = static_cast(status);
- if (ER_OK == status)
+ if (ER_OK == status)
{
result->Status = AllJoynStatus::Ok;
int16 argument0;
@@ -165,7 +183,7 @@ IAsyncOperation^ OnboardingConsumer::ConfigureWi
}
result->Status = static_cast(status);
}
-
+
alljoyn_message_destroy(message);
alljoyn_msgarg_destroy(inputs);
@@ -177,7 +195,7 @@ IAsyncOperation^ OnboardingConsumer::ConnectAsync()
return create_async([this]() -> OnboardingConnectResult^
{
auto result = ref new OnboardingConnectResult();
-
+
alljoyn_message message = alljoyn_message_create(m_nativeBusAttachment);
size_t argCount = 0;
alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount);
@@ -187,7 +205,7 @@ IAsyncOperation^ OnboardingConsumer::ConnectAsync()
{
status = alljoyn_proxybusobject_methodcall(
ProxyBusObject,
- "org.alljoyn.Onboarding",
+ m_interfaceName,
"Connect",
inputs,
argCount,
@@ -196,7 +214,7 @@ IAsyncOperation^ OnboardingConsumer::ConnectAsync()
0);
}
result->Status = static_cast(status);
-
+
alljoyn_message_destroy(message);
alljoyn_msgarg_destroy(inputs);
@@ -208,7 +226,7 @@ IAsyncOperation^ OnboardingConsumer::OffboardAsync()
return create_async([this]() -> OnboardingOffboardResult^
{
auto result = ref new OnboardingOffboardResult();
-
+
alljoyn_message message = alljoyn_message_create(m_nativeBusAttachment);
size_t argCount = 0;
alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount);
@@ -218,7 +236,7 @@ IAsyncOperation^ OnboardingConsumer::OffboardAsync()
{
status = alljoyn_proxybusobject_methodcall(
ProxyBusObject,
- "org.alljoyn.Onboarding",
+ m_interfaceName,
"Offboard",
inputs,
argCount,
@@ -227,7 +245,7 @@ IAsyncOperation^ OnboardingConsumer::OffboardAsync()
0);
}
result->Status = static_cast(status);
-
+
alljoyn_message_destroy(message);
alljoyn_msgarg_destroy(inputs);
@@ -239,7 +257,7 @@ IAsyncOperation^ OnboardingConsumer::GetScanInfoAs
return create_async([this]() -> OnboardingGetScanInfoResult^
{
auto result = ref new OnboardingGetScanInfoResult();
-
+
alljoyn_message message = alljoyn_message_create(m_nativeBusAttachment);
size_t argCount = 0;
alljoyn_msgarg inputs = alljoyn_msgarg_array_create(argCount);
@@ -249,7 +267,7 @@ IAsyncOperation^ OnboardingConsumer::GetScanInfoAs
{
status = alljoyn_proxybusobject_methodcall(
ProxyBusObject,
- "org.alljoyn.Onboarding",
+ m_interfaceName,
"GetScanInfo",
inputs,
argCount,
@@ -258,7 +276,7 @@ IAsyncOperation^ OnboardingConsumer::GetScanInfoAs
0);
}
result->Status = static_cast(status);
- if (ER_OK == status)
+ if (ER_OK == status)
{
result->Status = AllJoynStatus::Ok;
uint16 argument0;
@@ -292,7 +310,7 @@ IAsyncOperation^ OnboardingConsumer::GetScanInfoAs
}
result->Status = static_cast(status);
}
-
+
alljoyn_message_destroy(message);
alljoyn_msgarg_destroy(inputs);
@@ -305,10 +323,10 @@ IAsyncOperation^ OnboardingConsumer::GetVersionAsyn
return create_async([this]() -> OnboardingGetVersionResult^
{
PropertyGetContext getContext;
-
+
alljoyn_proxybusobject_getpropertyasync(
ProxyBusObject,
- "org.alljoyn.Onboarding",
+ m_interfaceName,
"Version",
[](QStatus status, alljoyn_proxybusobject obj, const alljoyn_msgarg value, void* context)
{
@@ -342,10 +360,10 @@ IAsyncOperation^ OnboardingConsumer::GetStateAsync()
return create_async([this]() -> OnboardingGetStateResult^
{
PropertyGetContext getContext;
-
+
alljoyn_proxybusobject_getpropertyasync(
ProxyBusObject,
- "org.alljoyn.Onboarding",
+ m_interfaceName,
"State",
[](QStatus status, alljoyn_proxybusobject obj, const alljoyn_msgarg value, void* context)
{
@@ -379,10 +397,10 @@ IAsyncOperation^ OnboardingConsumer::GetLastError
return create_async([this]() -> OnboardingGetLastErrorResult^
{
PropertyGetContext getContext;
-
+
alljoyn_proxybusobject_getpropertyasync(
ProxyBusObject,
- "org.alljoyn.Onboarding",
+ m_interfaceName,
"LastError",
[](QStatus status, alljoyn_proxybusobject obj, const alljoyn_msgarg value, void* context)
{
@@ -443,63 +461,59 @@ void OnboardingConsumer::CallConnectionResultSignalHandler(_In_ const alljoyn_in
}
}
-int32 OnboardingConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo)
+int32 OnboardingConsumer::Initialize(_In_ AllJoynServiceInfo^ serviceInfo)
{
- alljoyn_sessionlistener_callbacks callbacks =
- {
- AllJoynHelpers::SessionLostHandler,
- AllJoynHelpers::SessionMemberAddedHandler,
- AllJoynHelpers::SessionMemberRemovedHandler
- };
-
- alljoyn_busattachment_enableconcurrentcallbacks(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment));
-
- SessionListener = alljoyn_sessionlistener_create(&callbacks, m_weak);
- alljoyn_sessionopts sessionOpts = alljoyn_sessionopts_create(ALLJOYN_TRAFFIC_TYPE_MESSAGES, true, ALLJOYN_PROXIMITY_ANY, ALLJOYN_TRANSPORT_ANY);
-
std::vector sessionNameUtf8 = AllJoynHelpers::PlatformToMultibyteString(serviceInfo->UniqueName);
- RETURN_IF_QSTATUS_ERROR(alljoyn_busattachment_joinsession(
- m_nativeBusAttachment,
- &sessionNameUtf8[0],
- serviceInfo->SessionPort,
- SessionListener,
- &m_sessionId,
- sessionOpts));
- alljoyn_sessionopts_destroy(sessionOpts);
ServiceObjectPath = serviceInfo->ObjectPath;
std::vector objectPath = AllJoynHelpers::PlatformToMultibyteString(ServiceObjectPath);
+ RETURN_IF_QSTATUS_ERROR(AllJoynHelpers::CreateInterfaces(m_busAttachment, c_OnboardingIntrospectionXml));
+
+ m_session = create_task(AllJoynSession::GetFromServiceInfoAsync(serviceInfo, m_busAttachment)).get();
+ if (nullptr == m_session)
+ {
+ return AllJoynStatus::Fail;
+ }
+ else if (m_session->Status != AllJoynStatus::Ok)
+ {
+ return m_session->Status;
+ }
+
if (objectPath.empty())
{
return AllJoynStatus::Fail;
}
- ProxyBusObject = alljoyn_proxybusobject_create(m_nativeBusAttachment, &sessionNameUtf8[0], &objectPath[0], m_sessionId);
+ ProxyBusObject = alljoyn_proxybusobject_create(m_nativeBusAttachment, &sessionNameUtf8[0], &objectPath[0], m_session->Id);
if (nullptr == ProxyBusObject)
{
return AllJoynStatus::Fail;
}
- alljoyn_interfacedescription description = alljoyn_busattachment_getinterface(m_nativeBusAttachment, "org.alljoyn.Onboarding");
+ alljoyn_interfacedescription description = alljoyn_busattachment_getinterface(m_nativeBusAttachment, m_interfaceName);
if (nullptr == description)
{
return AllJoynStatus::Fail;
}
- RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::GetBusObject(m_nativeBusAttachment, AllJoynHelpers::PlatformToMultibyteString(ServiceObjectPath).data(), &m_busObject));
-
- if (!AllJoynBusObjectManager::BusObjectIsRegistered(m_nativeBusAttachment, m_busObject))
+ m_busObject = ref new Windows::Devices::AllJoyn::AllJoynBusObject(ServiceObjectPath, m_busAttachment);
+ m_nativeBusObject = AllJoynHelpers::GetInternalBusObject(m_busObject);
+
+ QStatus status = alljoyn_busobject_addinterface(m_nativeBusObject, description);
+ if ((status != ER_OK) && (status != ER_BUS_IFACE_ALREADY_EXISTS))
{
- RETURN_IF_QSTATUS_ERROR(alljoyn_busobject_addinterface(BusObject, description));
+ return status;
}
+
QStatus result = AddSignalHandler(
m_nativeBusAttachment,
description,
"ConnectionResult",
[](const alljoyn_interfacedescription_member* member, PCSTR srcPath, alljoyn_message message) { UNREFERENCED_PARAMETER(srcPath); CallConnectionResultSignalHandler(member, message); });
+
if (ER_OK != result)
{
return static_cast(result);
@@ -511,7 +525,7 @@ int32 OnboardingConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo)
bool authenticationMechanismsContainsNone = m_busAttachment->AuthenticationMechanisms->IndexOf(AllJoynAuthenticationMechanism::None, &noneMechanismIndex);
QCC_BOOL interfaceIsSecure = alljoyn_interfacedescription_issecure(description);
- // If the current set of AuthenticationMechanisms supports authentication,
+ // If the current set of AuthenticationMechanisms supports authentication,
// determine whether to secure the connection.
if (AllJoynHelpers::CanSecure(m_busAttachment->AuthenticationMechanisms))
{
@@ -520,11 +534,11 @@ int32 OnboardingConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo)
if (!authenticationMechanismsContainsNone || interfaceIsSecure)
{
RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_secureconnection(ProxyBusObject, QCC_FALSE));
- RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, true));
+ m_busObject->Start();
}
else
{
- RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, false));
+ m_busObject->Start();
}
}
else
@@ -537,13 +551,13 @@ int32 OnboardingConsumer::JoinSession(_In_ AllJoynServiceInfo^ serviceInfo)
}
else
{
- RETURN_IF_QSTATUS_ERROR(AllJoynBusObjectManager::TryRegisterBusObject(m_nativeBusAttachment, BusObject, false));
+ m_busObject->Start();
}
}
RETURN_IF_QSTATUS_ERROR(alljoyn_proxybusobject_addinterface(ProxyBusObject, description));
-
- m_signals->Initialize(BusObject, m_sessionId);
+
+ m_signals->Initialize(this);
return AllJoynStatus::Ok;
}
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.h
index ff1b84da82..f185881069 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.h
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingConsumer.h
@@ -24,38 +24,50 @@ namespace org { namespace alljoyn { namespace Onboarding {
public interface class IOnboardingConsumer
{
- event Windows::Foundation::TypedEventHandler^ SessionLost;
- event Windows::Foundation::TypedEventHandler^ SessionMemberAdded;
- event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved;
};
-public ref class OnboardingConsumer sealed : [Windows::Foundation::Metadata::Default] IOnboardingConsumer
+public ref class OnboardingConsumer sealed : [Windows::Foundation::Metadata::Default] IOnboardingConsumer, ISignalEmitter
{
public:
OnboardingConsumer(Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment);
virtual ~OnboardingConsumer();
- // Join the AllJoyn session specified by sessionName.
+ // Create a consumer from a device Id asynchronously.
//
- // This will usually be called after the unique name of a producer has been reported
- // in the Added callback on the Watcher.
- static Windows::Foundation::IAsyncOperation^ JoinSessionAsync(_In_ Windows::Devices::AllJoyn::AllJoynServiceInfo^ serviceInfo, _Inout_ OnboardingWatcher^ watcher);
+ // This is usually called to create a consumer after the unique name of a producer has been reported
+ // in the Added callback on the DeviceWatcher.
+ static Windows::Foundation::IAsyncOperation^ FromIdAsync(_In_ Platform::String^ deviceId);
+ // Create a consumer from a device Id asynchronously with the provided bus attachment.
+ //
+ // This is usually called to create a consumer after the unique name of a producer has been reported
+ // in the Added callback on the DeviceWatcher.
+ static Windows::Foundation::IAsyncOperation^ FromIdAsync(_In_ Platform::String^ deviceId, _In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment);
+
+ int32 OnboardingConsumer::Initialize(_In_ Windows::Devices::AllJoyn::AllJoynServiceInfo^ serviceInfo);
+
+ // "Sends the personal AP information to the onboardee"
// Call the ConfigureWiFi method
Windows::Foundation::IAsyncOperation^ ConfigureWiFiAsync(_In_ Platform::String^ interfaceMemberSSID, _In_ Platform::String^ interfaceMemberPassphrase, _In_ int16 interfaceMemberAuthType);
+ // "Tells the onboardee to connect to the personal AP"
// Call the Connect method
Windows::Foundation::IAsyncOperation^ ConnectAsync();
+ // "Tells the onboardee to disconnect from the personal AP"
// Call the Offboard method
Windows::Foundation::IAsyncOperation^ OffboardAsync();
+ // "Scans all the Wi-Fi access points in the onboardee's proximity"
// Call the GetScanInfo method
Windows::Foundation::IAsyncOperation^ GetScanInfoAsync();
+ // "Interface version number"
// Get the value of the Version property.
Windows::Foundation::IAsyncOperation^ GetVersionAsync();
+ // "The configuration state"
// Get the value of the State property.
Windows::Foundation::IAsyncOperation^ GetStateAsync();
+ // "The last error code and error message"
// Get the value of the LastError property.
Windows::Foundation::IAsyncOperation^ GetLastErrorAsync();
@@ -66,91 +78,37 @@ public ref class OnboardingConsumer sealed : [Windows::Foundation::Metadata::De
OnboardingSignals^ get() { return m_signals; }
}
- // This event will fire whenever the consumer loses the session that it is a member of.
- virtual event Windows::Foundation::TypedEventHandler^ SessionLost
- {
- Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler)
- {
- return _SessionLost += ref new Windows::Foundation::EventHandler
- ([handler](Platform::Object^ sender, Platform::Object^ args)
- {
- handler->Invoke(safe_cast(sender), safe_cast(args));
- }, Platform::CallbackContext::Same);
- }
- void remove(Windows::Foundation::EventRegistrationToken token)
- {
- _SessionLost -= token;
- }
- internal:
- void raise(OnboardingConsumer^ sender, Windows::Devices::AllJoyn::AllJoynSessionLostEventArgs^ args)
- {
- _SessionLost(sender, args);
- }
+ // Used to get the name of the interface this consumer implements.
+ static property Platform::String^ InterfaceName
+ {
+ Platform::String^ get() { return AllJoynHelpers::MultibyteToPlatformString(m_interfaceName); }
}
- // This event will fire whenever a member joins the session.
- virtual event Windows::Foundation::TypedEventHandler^ SessionMemberAdded
- {
- Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler)
- {
- return _SessionMemberAdded += ref new Windows::Foundation::EventHandler
- ([handler](Platform::Object^ sender, Platform::Object^ args)
- {
- handler->Invoke(safe_cast(sender), safe_cast(args));
- }, Platform::CallbackContext::Same);
- }
- void remove(Windows::Foundation::EventRegistrationToken token)
- {
- _SessionMemberAdded -= token;
- }
- internal:
- void raise(OnboardingConsumer^ sender, Windows::Devices::AllJoyn::AllJoynSessionMemberAddedEventArgs^ args)
- {
- _SessionMemberAdded(sender, args);
- }
+ virtual property Windows::Devices::AllJoyn::AllJoynBusObject^ BusObject
+ {
+ Windows::Devices::AllJoyn::AllJoynBusObject^ get() { return m_busObject; }
}
- // This event will fire whenever a member leaves the session.
- virtual event Windows::Foundation::TypedEventHandler^ SessionMemberRemoved
- {
- Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler)
- {
- return _SessionMemberRemoved += ref new Windows::Foundation::EventHandler
- ([handler](Platform::Object^ sender, Platform::Object^ args)
- {
- handler->Invoke(safe_cast(sender), safe_cast(args));
- }, Platform::CallbackContext::Same);
- }
- void remove(Windows::Foundation::EventRegistrationToken token)
- {
- _SessionMemberRemoved -= token;
- }
- internal:
- void raise(OnboardingConsumer^ sender, Windows::Devices::AllJoyn::AllJoynSessionMemberRemovedEventArgs^ args)
- {
- _SessionMemberRemoved(sender, args);
- }
+ virtual property Windows::Devices::AllJoyn::AllJoynSession^ Session
+ {
+ Windows::Devices::AllJoyn::AllJoynSession^ get() { return m_session; }
}
internal:
// Consumers do not support property get.
- QStatus OnPropertyGet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _Inout_ alljoyn_msgarg val)
- {
- UNREFERENCED_PARAMETER(interfaceName); UNREFERENCED_PARAMETER(propertyName); UNREFERENCED_PARAMETER(val);
- return ER_NOT_IMPLEMENTED;
+ QStatus OnPropertyGet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _Inout_ alljoyn_msgarg val)
+ {
+ UNREFERENCED_PARAMETER(interfaceName); UNREFERENCED_PARAMETER(propertyName); UNREFERENCED_PARAMETER(val);
+ return ER_NOT_IMPLEMENTED;
}
// Consumers do not support property set.
- QStatus OnPropertySet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg val)
- {
+ QStatus OnPropertySet(_In_ PCSTR interfaceName, _In_ PCSTR propertyName, _In_ alljoyn_msgarg val)
+ {
UNREFERENCED_PARAMETER(interfaceName); UNREFERENCED_PARAMETER(propertyName); UNREFERENCED_PARAMETER(val);
return ER_NOT_IMPLEMENTED;
}
- void OnSessionLost(_In_ alljoyn_sessionid sessionId, _In_ alljoyn_sessionlostreason reason);
- void OnSessionMemberAdded(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName);
- void OnSessionMemberRemoved(_In_ alljoyn_sessionid sessionId, _In_ PCSTR uniqueName);
-
void OnPropertyChanged(_In_ alljoyn_proxybusobject obj, _In_ PCSTR interfaceName, _In_ const alljoyn_msgarg changed, _In_ const alljoyn_msgarg invalidated);
property Platform::String^ ServiceObjectPath
@@ -165,43 +123,26 @@ public ref class OnboardingConsumer sealed : [Windows::Foundation::Metadata::De
void set(alljoyn_proxybusobject value) { m_proxyBusObject = value; }
}
- property alljoyn_busobject BusObject
- {
- alljoyn_busobject get() { return m_busObject; }
- void set(alljoyn_busobject value) { m_busObject = value; }
- }
-
- property alljoyn_sessionlistener SessionListener
- {
- alljoyn_sessionlistener get() { return m_sessionListener; }
- void set(alljoyn_sessionlistener value) { m_sessionListener = value; }
- }
-
- property alljoyn_sessionid SessionId
- {
- alljoyn_sessionid get() { return m_sessionId; }
- }
-
private:
virtual event Windows::Foundation::EventHandler^ _SessionLost;
virtual event Windows::Foundation::EventHandler^ _SessionMemberAdded;
virtual event Windows::Foundation::EventHandler^ _SessionMemberRemoved;
- int32 JoinSession(_In_ Windows::Devices::AllJoyn::AllJoynServiceInfo^ serviceInfo);
-
// Register a callback function to handle incoming signals.
QStatus AddSignalHandler(_In_ alljoyn_busattachment busAttachment, _In_ alljoyn_interfacedescription interfaceDescription, _In_ PCSTR methodName, _In_ alljoyn_messagereceiver_signalhandler_ptr handler);
+ // "This signal is emitted when the connection attempt against the personal AP is completed"
static void CallConnectionResultSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message);
-
+
Windows::Devices::AllJoyn::AllJoynBusAttachment^ m_busAttachment;
+ Windows::Devices::AllJoyn::AllJoynBusObject^ m_busObject;
+ Windows::Devices::AllJoyn::AllJoynSession^ m_session;
OnboardingSignals^ m_signals;
Platform::String^ m_ServiceObjectPath;
alljoyn_proxybusobject m_proxyBusObject;
- alljoyn_busobject m_busObject;
alljoyn_sessionlistener m_sessionListener;
- alljoyn_sessionid m_sessionId;
+ alljoyn_busobject m_nativeBusObject;
alljoyn_busattachment m_nativeBusAttachment;
// Used to pass a pointer to this class to callbacks
@@ -211,6 +152,9 @@ public ref class OnboardingConsumer sealed : [Windows::Foundation::Metadata::De
// handlers, but the current AllJoyn C API does not allow passing a context to these
// callbacks.
static std::map SourceInterfaces;
+
+ // The name of the interface this consumer implements.
+ static PCSTR m_interfaceName;
};
} } }
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingEventArgs.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingEventArgs.h
index 5b9cee1df3..ff8beb311c 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingEventArgs.h
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingEventArgs.h
@@ -23,6 +23,7 @@
namespace org { namespace alljoyn { namespace Onboarding {
// Signals
+// "This signal is emitted when the connection attempt against the personal AP is completed"
public ref class OnboardingConnectionResultReceivedEventArgs sealed
{
public:
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingLegacySignals.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingLegacySignals.cpp
new file mode 100644
index 0000000000..3943ad7944
--- /dev/null
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingLegacySignals.cpp
@@ -0,0 +1,67 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+//
+//*********************************************************
+//-----------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
+//
+//-----------------------------------------------------------------------------
+#include "pch.h"
+
+using namespace Microsoft::WRL;
+using namespace Platform;
+using namespace Windows::Devices::AllJoyn;
+using namespace Windows::Foundation;
+using namespace org::alljoyn::Onboarding;
+
+void OnboardingLegacySignals::Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId)
+{
+ m_busObject = busObject;
+ m_sessionId = sessionId;
+
+ auto interfaceDefinition = alljoyn_busattachment_getinterface(alljoyn_busobject_getbusattachment(busObject), "org.alljoyn.Onboarding");
+ alljoyn_interfacedescription_getmember(interfaceDefinition, "ConnectionResult", &m_memberConnectionResult);
+}
+
+void OnboardingLegacySignals::ConnectionResult(_In_ Onboarding^ interfaceMemberArg)
+{
+ if (nullptr == m_busObject)
+ {
+ return;
+ }
+
+ size_t argCount = 1;
+ alljoyn_msgarg arguments = alljoyn_msgarg_array_create(argCount);
+ (void)TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(arguments, 0), "(ns)", interfaceMemberArg);
+
+ alljoyn_busobject_signal(
+ m_busObject,
+ NULL, // Generated code only supports broadcast signals.
+ m_sessionId,
+ m_memberConnectionResult,
+ arguments,
+ argCount,
+ 0, // A signal with a TTL of 0 will be sent to every member of the session, regardless of how long it takes to deliver the message
+ ALLJOYN_MESSAGE_FLAG_GLOBAL_BROADCAST, // Broadcast to everyone in the session.
+ NULL); // The generated code does not need the generated signal message
+
+ alljoyn_msgarg_destroy(arguments);
+}
+
+void OnboardingLegacySignals::CallConnectionResultReceived(_In_ OnboardingLegacySignals^ sender, _In_ OnboardingConnectionResultReceivedEventArgs^ args)
+{
+ ConnectionResultReceived(sender, args);
+}
+
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingLegacySignals.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingLegacySignals.h
new file mode 100644
index 0000000000..3e3aac566d
--- /dev/null
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingLegacySignals.h
@@ -0,0 +1,74 @@
+//*********************************************************
+//
+// Copyright (c) Microsoft. All rights reserved.
+// This code is licensed under the MIT License (MIT).
+// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
+// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
+// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
+// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
+//
+//*********************************************************
+//-----------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
+//
+//-----------------------------------------------------------------------------
+#pragma once
+
+namespace org { namespace alljoyn { namespace Onboarding {
+
+ref class OnboardingLegacySignals;
+
+public interface class IOnboardingLegacySignals
+{
+ event Windows::Foundation::TypedEventHandler^ ConnectionResultReceived;
+};
+
+public ref class OnboardingLegacySignals sealed : [Windows::Foundation::Metadata::Default] IOnboardingLegacySignals
+{
+public:
+ // "This signal is emitted when the connection attempt against the personal AP is completed"
+ // Calling this method will send the ConnectionResult signal to every member of the session.
+ void ConnectionResult(_In_ Onboarding^ interfaceMemberArg);
+
+ // This event fires whenever the ConnectionResult signal is sent by another member of the session.
+ virtual event Windows::Foundation::TypedEventHandler^ ConnectionResultReceived
+ {
+ Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler)
+ {
+ return _ConnectionResultReceived += ref new Windows::Foundation::EventHandler
+ ([handler](Platform::Object^ sender, Platform::Object^ args)
+ {
+ handler->Invoke(safe_cast(sender), safe_cast(args));
+ }, Platform::CallbackContext::Same);
+ }
+ void remove(Windows::Foundation::EventRegistrationToken token)
+ {
+ _ConnectionResultReceived -= token;
+ }
+ internal:
+ void raise(OnboardingLegacySignals^ sender, OnboardingConnectionResultReceivedEventArgs^ args)
+ {
+ _ConnectionResultReceived(sender, args);
+ }
+ }
+
+internal:
+ void Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId);
+ void CallConnectionResultReceived(_In_ OnboardingLegacySignals^ sender, _In_ OnboardingConnectionResultReceivedEventArgs^ args);
+
+private:
+ alljoyn_busobject m_busObject;
+ alljoyn_sessionid m_sessionId;
+
+ virtual event Windows::Foundation::EventHandler^ _ConnectionResultReceived;
+
+ alljoyn_interfacedescription_member m_memberConnectionResult;
+};
+
+} } }
\ No newline at end of file
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingMethodResults.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingMethodResults.h
index 538d345cb3..eabd9c7507 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingMethodResults.h
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingMethodResults.h
@@ -210,6 +210,7 @@ public ref class OnboardingGetVersionResult sealed
void set(_In_ int32 value) { m_status = value; }
}
+ // "Interface version number"
property uint16 Version
{
uint16 get() { return m_value; }
@@ -250,6 +251,7 @@ public ref class OnboardingGetStateResult sealed
void set(_In_ int32 value) { m_status = value; }
}
+ // "The configuration state"
property int16 State
{
int16 get() { return m_value; }
@@ -290,6 +292,7 @@ public ref class OnboardingGetLastErrorResult sealed
void set(_In_ int32 value) { m_status = value; }
}
+ // "The last error code and error message"
property OnboardingLastError^ LastError
{
OnboardingLastError^ get() { return m_value; }
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.cpp
index 053efac993..904d310aeb 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.cpp
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.cpp
@@ -39,7 +39,7 @@ OnboardingProducer::OnboardingProducer(AllJoynBusAttachment^ busAttachment)
{
m_weak = new WeakReference(this);
ServiceObjectPath = ref new String(L"/Service");
- m_signals = ref new OnboardingSignals();
+ m_signals = ref new OnboardingLegacySignals();
m_busAttachmentStateChangedToken.Value = 0;
}
@@ -635,4 +635,4 @@ PCSTR org::alljoyn::Onboarding::c_OnboardingIntrospectionXml = " "
" "
""
-;
+;
\ No newline at end of file
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.h
index e93d5f6526..497043ca94 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.h
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingProducer.h
@@ -48,9 +48,9 @@ public ref class OnboardingProducer sealed : [Windows::Foundation::Metadata::Def
}
// Used to send signals or register functions to handle received signals.
- property OnboardingSignals^ Signals
+ property OnboardingLegacySignals^ Signals
{
- OnboardingSignals^ get() { return m_signals; }
+ OnboardingLegacySignals^ get() { return m_signals; }
}
// This event will fire whenever this producer is stopped.
@@ -206,10 +206,15 @@ public ref class OnboardingProducer sealed : [Windows::Foundation::Metadata::Def
virtual event Windows::Foundation::EventHandler^ _SessionMemberAdded;
virtual event Windows::Foundation::EventHandler^ _SessionMemberRemoved;
+ // "Sends the personal AP information to the onboardee"
static void CallConfigureWiFiHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message);
+ // "Tells the onboardee to connect to the personal AP"
static void CallConnectHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message);
+ // "Tells the onboardee to disconnect from the personal AP"
static void CallOffboardHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message);
+ // "Scans all the Wi-Fi access points in the onboardee's proximity"
static void CallGetScanInfoHandler(_Inout_ alljoyn_busobject busObject, _In_ alljoyn_message message);
+ // "This signal is emitted when the connection attempt against the personal AP is completed"
static void CallConnectionResultSignalHandler(_In_ const alljoyn_interfacedescription_member* member, _In_ alljoyn_message message);
// Register a callback function to handle methods.
@@ -221,7 +226,7 @@ public ref class OnboardingProducer sealed : [Windows::Foundation::Metadata::Def
Windows::Devices::AllJoyn::AllJoynBusAttachment^ m_busAttachment;
Windows::Foundation::EventRegistrationToken m_busAttachmentStateChangedToken;
- OnboardingSignals^ m_signals;
+ OnboardingLegacySignals^ m_signals;
IOnboardingService^ m_serviceInterface;
Platform::String^ m_ServiceObjectPath;
@@ -241,4 +246,4 @@ public ref class OnboardingProducer sealed : [Windows::Foundation::Metadata::Def
static std::map SourceInterfaces;
};
-} } }
+} } }
\ No newline at end of file
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.cpp
index abdc80b635..1a86b78f0c 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.cpp
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.cpp
@@ -9,24 +9,13 @@
//
//*********************************************************
//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// Tool: AllJoynCodeGenerator.exe
+//
+// This code was generated by a tool.
//
-// This tool is located in the Windows 10 SDK and the Windows 10 AllJoyn
-// Visual Studio Extension in the Visual Studio Gallery.
-//
-// The generated code should be packaged in a Windows 10 C++/CX Runtime
-// Component which can be consumed in any UWP-supported language using
-// APIs that are available in Windows.Devices.AllJoyn.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
-// Using AllJoynCodeGenerator - Invoke the following command with a valid
-// Introspection XML file and a writable output directory:
-// AllJoynCodeGenerator -i -o
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
//
//-----------------------------------------------------------------------------
#include "pch.h"
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.h
index b9fcff51e7..c6a5f2a4d8 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.h
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventAdapter.h
@@ -9,24 +9,13 @@
//
//*********************************************************
//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// Tool: AllJoynCodeGenerator.exe
+//
+// This code was generated by a tool.
//
-// This tool is located in the Windows 10 SDK and the Windows 10 AllJoyn
-// Visual Studio Extension in the Visual Studio Gallery.
-//
-// The generated code should be packaged in a Windows 10 C++/CX Runtime
-// Component which can be consumed in any UWP-supported language using
-// APIs that are available in Windows.Devices.AllJoyn.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
-// Using AllJoynCodeGenerator - Invoke the following command with a valid
-// Introspection XML file and a writable output directory:
-// AllJoynCodeGenerator -i -o
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
//
//-----------------------------------------------------------------------------
#pragma once
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.cpp
index 19e7b05b6f..fde0ade6cb 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.cpp
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.cpp
@@ -9,24 +9,13 @@
//
//*********************************************************
//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// Tool: AllJoynCodeGenerator.exe
+//
+// This code was generated by a tool.
//
-// This tool is located in the Windows 10 SDK and the Windows 10 AllJoyn
-// Visual Studio Extension in the Visual Studio Gallery.
-//
-// The generated code should be packaged in a Windows 10 C++/CX Runtime
-// Component which can be consumed in any UWP-supported language using
-// APIs that are available in Windows.Devices.AllJoyn.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
-// Using AllJoynCodeGenerator - Invoke the following command with a valid
-// Introspection XML file and a writable output directory:
-// AllJoynCodeGenerator -i -o
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
//
//-----------------------------------------------------------------------------
#include "pch.h"
@@ -53,7 +42,7 @@ OnboardingConfigureWiFiCalledEventArgs::OnboardingConfigureWiFiCalledEventArgs(
m_interfaceMemberPassphrase(interfaceMemberPassphrase),
m_interfaceMemberAuthType(interfaceMemberAuthType)
{
- m_result = OnboardingConfigureWiFiResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
+ m_result = OnboardingConfigureWiFiResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
}
Deferral^ OnboardingConfigureWiFiCalledEventArgs::GetDeferral()
@@ -128,7 +117,7 @@ OnboardingConnectCalledEventArgs::OnboardingConnectCalledEventArgs(
m_completionsRequired(0),
m_messageInfo(info)
{
- m_result = OnboardingConnectResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
+ m_result = OnboardingConnectResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
}
Deferral^ OnboardingConnectCalledEventArgs::GetDeferral()
@@ -203,7 +192,7 @@ OnboardingOffboardCalledEventArgs::OnboardingOffboardCalledEventArgs(
m_completionsRequired(0),
m_messageInfo(info)
{
- m_result = OnboardingOffboardResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
+ m_result = OnboardingOffboardResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
}
Deferral^ OnboardingOffboardCalledEventArgs::GetDeferral()
@@ -278,7 +267,7 @@ OnboardingGetScanInfoCalledEventArgs::OnboardingGetScanInfoCalledEventArgs(
m_completionsRequired(0),
m_messageInfo(info)
{
- m_result = OnboardingGetScanInfoResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
+ m_result = OnboardingGetScanInfoResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
}
Deferral^ OnboardingGetScanInfoCalledEventArgs::GetDeferral()
@@ -354,7 +343,7 @@ OnboardingGetVersionRequestedEventArgs::OnboardingGetVersionRequestedEventArgs(
m_completionsRequired(0),
m_messageInfo(info)
{
- m_result = OnboardingGetVersionResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
+ m_result = OnboardingGetVersionResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
}
Deferral^ OnboardingGetVersionRequestedEventArgs::GetDeferral()
@@ -429,7 +418,7 @@ OnboardingGetStateRequestedEventArgs::OnboardingGetStateRequestedEventArgs(
m_completionsRequired(0),
m_messageInfo(info)
{
- m_result = OnboardingGetStateResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
+ m_result = OnboardingGetStateResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
}
Deferral^ OnboardingGetStateRequestedEventArgs::GetDeferral()
@@ -504,7 +493,7 @@ OnboardingGetLastErrorRequestedEventArgs::OnboardingGetLastErrorRequestedEventAr
m_completionsRequired(0),
m_messageInfo(info)
{
- m_result = OnboardingGetLastErrorResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
+ m_result = OnboardingGetLastErrorResult::CreateFailureResult(ER_NOT_IMPLEMENTED);
}
Deferral^ OnboardingGetLastErrorRequestedEventArgs::GetDeferral()
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.h
index 3610c12a76..d09643578e 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.h
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingServiceEventArgs.h
@@ -9,24 +9,13 @@
//
//*********************************************************
//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// Tool: AllJoynCodeGenerator.exe
+//
+// This code was generated by a tool.
//
-// This tool is located in the Windows 10 SDK and the Windows 10 AllJoyn
-// Visual Studio Extension in the Visual Studio Gallery.
-//
-// The generated code should be packaged in a Windows 10 C++/CX Runtime
-// Component which can be consumed in any UWP-supported language using
-// APIs that are available in Windows.Devices.AllJoyn.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
-// Using AllJoynCodeGenerator - Invoke the following command with a valid
-// Introspection XML file and a writable output directory:
-// AllJoynCodeGenerator -i -o
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
//
//-----------------------------------------------------------------------------
#pragma once
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.cpp
index 78d54a8d2c..5baf4b55f6 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.cpp
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.cpp
@@ -26,18 +26,17 @@ using namespace Windows::Devices::AllJoyn;
using namespace Windows::Foundation;
using namespace org::alljoyn::Onboarding;
-void OnboardingSignals::Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId)
+void OnboardingSignals::Initialize(_In_ ISignalEmitter^ emitter)
{
- m_busObject = busObject;
- m_sessionId = sessionId;
-
- auto interfaceDefinition = alljoyn_busattachment_getinterface(alljoyn_busobject_getbusattachment(busObject), "org.alljoyn.Onboarding");
+ m_emitter = emitter;
+ alljoyn_busattachment nativeBusAttachment = AllJoynHelpers::GetInternalBusAttachment(m_emitter->BusObject->BusAttachment);
+ auto interfaceDefinition = alljoyn_busattachment_getinterface(nativeBusAttachment, "org.alljoyn.Onboarding");
alljoyn_interfacedescription_getmember(interfaceDefinition, "ConnectionResult", &m_memberConnectionResult);
}
void OnboardingSignals::ConnectionResult(_In_ Onboarding^ interfaceMemberArg)
{
- if (nullptr == m_busObject)
+ if (nullptr == AllJoynHelpers::GetInternalBusObject(m_emitter->BusObject))
{
return;
}
@@ -47,9 +46,9 @@ void OnboardingSignals::ConnectionResult(_In_ Onboarding^ interfaceMemberArg)
(void)TypeConversionHelpers::SetAllJoynMessageArg(alljoyn_msgarg_array_element(arguments, 0), "(ns)", interfaceMemberArg);
alljoyn_busobject_signal(
- m_busObject,
+ AllJoynHelpers::GetInternalBusObject(m_emitter->BusObject),
NULL, // Generated code only supports broadcast signals.
- m_sessionId,
+ m_emitter->Session->Id,
m_memberConnectionResult,
arguments,
argCount,
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.h
index 1453c464cc..c6a6adb804 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.h
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingSignals.h
@@ -32,6 +32,7 @@ public interface class IOnboardingSignals
public ref class OnboardingSignals sealed : [Windows::Foundation::Metadata::Default] IOnboardingSignals
{
public:
+ // "This signal is emitted when the connection attempt against the personal AP is completed"
// Calling this method will send the ConnectionResult signal to every member of the session.
void ConnectionResult(_In_ Onboarding^ interfaceMemberArg);
@@ -58,12 +59,11 @@ public ref class OnboardingSignals sealed : [Windows::Foundation::Metadata::Defa
}
internal:
- void Initialize(_In_ alljoyn_busobject busObject, _In_ alljoyn_sessionid sessionId);
+ void Initialize(_In_ ISignalEmitter^ emitter);
void CallConnectionResultReceived(_In_ OnboardingSignals^ sender, _In_ OnboardingConnectionResultReceivedEventArgs^ args);
private:
- alljoyn_busobject m_busObject;
- alljoyn_sessionid m_sessionId;
+ ISignalEmitter^ m_emitter;
virtual event Windows::Foundation::EventHandler^ _ConnectionResultReceived;
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingWatcher.cpp b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingWatcher.cpp
deleted file mode 100644
index 2d284cb4d5..0000000000
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingWatcher.cpp
+++ /dev/null
@@ -1,142 +0,0 @@
-//*********************************************************
-//
-// Copyright (c) Microsoft. All rights reserved.
-// This code is licensed under the MIT License (MIT).
-// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
-// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
-// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
-// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
-//
-//*********************************************************
-//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
-//
-//-----------------------------------------------------------------------------
-#include "pch.h"
-
-using namespace concurrency;
-using namespace Microsoft::WRL;
-using namespace Platform;
-using namespace Windows::Foundation;
-using namespace Windows::Devices::AllJoyn;
-using namespace org::alljoyn::Onboarding;
-
-OnboardingWatcher::OnboardingWatcher(AllJoynBusAttachment^ busAttachment) :
- m_aboutListener(nullptr)
-{
- m_busAttachment = busAttachment;
- m_weak = new WeakReference(this);
- m_busAttachmentStateChangedToken.Value = 0;
-}
-
-OnboardingWatcher::~OnboardingWatcher()
-{
- UnregisterFromBus();
-}
-
-void OnboardingWatcher::UnregisterFromBus()
-{
- if (nullptr != m_aboutListener)
- {
- PCSTR interfaces[] = { "org.alljoyn.Onboarding" };
- alljoyn_busattachment_cancelwhoimplements_interfaces(
- AllJoynHelpers::GetInternalBusAttachment(m_busAttachment),
- interfaces,
- _countof(interfaces));
-
- alljoyn_busattachment_unregisteraboutlistener(AllJoynHelpers::GetInternalBusAttachment(m_busAttachment), m_aboutListener);
- alljoyn_aboutlistener_destroy(m_aboutListener);
- m_aboutListener = nullptr;
- }
- if ((nullptr != m_busAttachment) && (0 != m_busAttachmentStateChangedToken.Value))
- {
- m_busAttachment->StateChanged -= m_busAttachmentStateChangedToken;
- }
-}
-
-void OnboardingWatcher::OnAnnounce(
- _In_ PCSTR name,
- _In_ uint16_t version,
- _In_ alljoyn_sessionport port,
- _In_ alljoyn_msgarg objectDescriptionArg,
- _In_ const alljoyn_msgarg aboutDataArg)
-{
- UNREFERENCED_PARAMETER(version);
- UNREFERENCED_PARAMETER(aboutDataArg);
-
- alljoyn_aboutobjectdescription objectDescription = alljoyn_aboutobjectdescription_create_full(objectDescriptionArg);
-
- if (alljoyn_aboutobjectdescription_hasinterface(objectDescription, "org.alljoyn.Onboarding"))
- {
- AllJoynServiceInfo^ args = ref new AllJoynServiceInfo(
- AllJoynHelpers::MultibyteToPlatformString(name),
- AllJoynHelpers::GetObjectPath(objectDescription, "org.alljoyn.Onboarding"),
- port);
- Added(this, args);
- }
- alljoyn_aboutobjectdescription_destroy(objectDescription);
-}
-
-void OnboardingWatcher::BusAttachmentStateChanged(_In_ AllJoynBusAttachment^ sender, _In_ AllJoynBusAttachmentStateChangedEventArgs^ args)
-{
- if (args->State == AllJoynBusAttachmentState::Connected)
- {
- alljoyn_aboutlistener_callback callbacks =
- {
- AllJoynHelpers::AnnounceHandler
- };
- m_aboutListener = alljoyn_aboutlistener_create(&callbacks, m_weak);
-
- alljoyn_busattachment_registeraboutlistener(AllJoynHelpers::GetInternalBusAttachment(sender), m_aboutListener);
- PCSTR interfaces[] = { "org.alljoyn.Onboarding" };
-
- auto status = alljoyn_busattachment_whoimplements_interfaces(
- AllJoynHelpers::GetInternalBusAttachment(sender),
- interfaces,
- _countof(interfaces));
- if (ER_OK != status)
- {
- StopInternal(status);
- }
- }
- else if (args->State == AllJoynBusAttachmentState::Disconnected)
- {
- StopInternal(ER_BUS_STOPPING);
- }
-}
-
-void OnboardingWatcher::Start()
-{
- if (nullptr == m_busAttachment)
- {
- StopInternal(ER_FAIL);
- return;
- }
-
- int32 result = AllJoynHelpers::CreateInterfaces(m_busAttachment, c_OnboardingIntrospectionXml);
- if (result != AllJoynStatus::Ok)
- {
- StopInternal(result);
- return;
- }
-
- m_busAttachmentStateChangedToken = m_busAttachment->StateChanged += ref new TypedEventHandler(this, &OnboardingWatcher::BusAttachmentStateChanged);
- m_busAttachment->Connect();
-}
-
-void OnboardingWatcher::Stop()
-{
- StopInternal(AllJoynStatus::Ok);
-}
-
-void OnboardingWatcher::StopInternal(int32 status)
-{
- UnregisterFromBus();
- Stopped(this, ref new AllJoynProducerStoppedEventArgs(status));
-}
\ No newline at end of file
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingWatcher.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingWatcher.h
deleted file mode 100644
index 48a811a800..0000000000
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/OnboardingWatcher.h
+++ /dev/null
@@ -1,127 +0,0 @@
-//*********************************************************
-//
-// Copyright (c) Microsoft. All rights reserved.
-// This code is licensed under the MIT License (MIT).
-// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
-// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
-// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
-// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
-//
-//*********************************************************
-//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
-//
-//-----------------------------------------------------------------------------
-#pragma once
-
-namespace org { namespace alljoyn { namespace Onboarding {
-
-ref class OnboardingWatcher;
-
-public interface class IOnboardingWatcher
-{
- event Windows::Foundation::TypedEventHandler^ Added;
- event Windows::Foundation::TypedEventHandler^ Stopped;
-};
-
-public ref class OnboardingWatcher sealed : [Windows::Foundation::Metadata::Default] IOnboardingWatcher
-{
-public:
- OnboardingWatcher(Windows::Devices::AllJoyn::AllJoynBusAttachment^ busAttachment);
- virtual ~OnboardingWatcher();
-
- // This event will fire whenever a producer for this service is found.
- virtual event Windows::Foundation::TypedEventHandler^ Added
- {
- Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler)
- {
- return _Added += ref new Windows::Foundation::EventHandler
- ([handler](Platform::Object^ sender, Platform::Object^ args)
- {
- handler->Invoke(safe_cast(sender), safe_cast(args));
- }, Platform::CallbackContext::Same);
- }
- void remove(Windows::Foundation::EventRegistrationToken token)
- {
- _Added -= token;
- }
- internal:
- void raise(OnboardingWatcher^ sender, Windows::Devices::AllJoyn::AllJoynServiceInfo^ args)
- {
- _Added(sender, args);
- }
- }
-
- // This event will fire whenever the watcher is stopped.
- virtual event Windows::Foundation::TypedEventHandler^ Stopped
- {
- Windows::Foundation::EventRegistrationToken add(Windows::Foundation::TypedEventHandler^ handler)
- {
- return _Stopped += ref new Windows::Foundation::EventHandler
- ([handler](Platform::Object^ sender, Platform::Object^ args)
- {
- handler->Invoke(safe_cast(sender), safe_cast(args));
- }, Platform::CallbackContext::Same);
- }
- void remove(Windows::Foundation::EventRegistrationToken token)
- {
- _Stopped -= token;
- }
- internal:
- void raise(OnboardingWatcher^ sender, Windows::Devices::AllJoyn::AllJoynProducerStoppedEventArgs^ args)
- {
- _Stopped(sender, args);
- }
- }
-
- // Start watching for producers advertising this service.
- void Start();
-
- // Stop watching for producers for this service.
- void Stop();
-
-internal:
- void OnAnnounce(
- _In_ PCSTR name,
- _In_ uint16_t version,
- _In_ alljoyn_sessionport port,
- _In_ alljoyn_msgarg objectDescriptionArg,
- _In_ const alljoyn_msgarg aboutDataArg);
-
- void OnPropertyChanged(_In_ PCSTR prop_name, _In_ alljoyn_msgarg prop_value)
- {
- UNREFERENCED_PARAMETER(prop_name); UNREFERENCED_PARAMETER(prop_value);
- }
-
- property Windows::Devices::AllJoyn::AllJoynBusAttachment^ BusAttachment
- {
- Windows::Devices::AllJoyn::AllJoynBusAttachment^ get() { return m_busAttachment; }
- }
-
- // Stop watching for producers advertising this service and pass status to anyone listening for the Stopped event.
- void StopInternal(int32 status);
-
- void BusAttachmentStateChanged(_In_ Windows::Devices::AllJoyn::AllJoynBusAttachment^ sender, _In_ Windows::Devices::AllJoyn::AllJoynBusAttachmentStateChangedEventArgs^ args);
-
-private:
- virtual event Windows::Foundation::EventHandler^ _Added;
- virtual event Windows::Foundation::EventHandler^ _Stopped;
-
- void UnregisterFromBus();
-
- Windows::Devices::AllJoyn::AllJoynBusAttachment^ m_busAttachment;
- Windows::Foundation::EventRegistrationToken m_busAttachmentStateChangedToken;
-
- alljoyn_aboutlistener m_aboutListener;
-
- // Used to pass a pointer to this class to callbacks.
- Platform::WeakReference* m_weak;
-};
-
-} } }
\ No newline at end of file
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj b/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj
index 2e88d35a2e..ad22319a04 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj
@@ -221,17 +221,17 @@
-
+
+
-
@@ -239,11 +239,11 @@
+
-
Create
Create
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj.filters b/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj.filters
index 00ac637f66..bc561c71cb 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj.filters
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/Scenario2WinRTComponent.vcxproj.filters
@@ -11,27 +11,27 @@
+
-
-
+
+
-
\ No newline at end of file
diff --git a/Samples/AllJoyn/Common/Scenario2WinRTComponent/pch.h b/Samples/AllJoyn/Common/Scenario2WinRTComponent/pch.h
index 158fc61b39..754d9b45ce 100644
--- a/Samples/AllJoyn/Common/Scenario2WinRTComponent/pch.h
+++ b/Samples/AllJoyn/Common/Scenario2WinRTComponent/pch.h
@@ -45,8 +45,8 @@
#include "OnboardingEventArgs.h"
#include "IOnboardingService.h"
#include "OnboardingSignals.h"
+#include "OnboardingLegacySignals.h"
#include "OnboardingProducer.h"
-#include "OnboardingWatcher.h"
#include "OnboardingConsumer.h"
#include "OnboardingServiceEventArgs.h"
#include "OnboardingServiceEventAdapter.h"
\ No newline at end of file
diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1ViewModel.cs b/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1ViewModel.cs
index c17beb20a1..df9a986bb0 100644
--- a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1ViewModel.cs
+++ b/Samples/AllJoyn/ConsumerExperiences/cs/Scenario1ViewModel.cs
@@ -12,12 +12,14 @@
using com.microsoft.Samples.SecureInterface;
using SDKTemplate;
using System;
+using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using System.Windows.Input;
using Windows.Data.Xml.Dom;
using Windows.Devices.AllJoyn;
+using Windows.Devices.Enumeration;
using Windows.UI.Core;
using Windows.UI.Notifications;
using Windows.UI.Xaml;
@@ -29,7 +31,7 @@ class Scenario1ViewModel : INotifyPropertyChanged
private MainPage m_rootPage;
private CoreDispatcher m_dispatcher;
private AllJoynBusAttachment m_busAttachment = null;
- private SecureInterfaceWatcher m_watcher = null;
+ private DeviceWatcher m_watcher = null;
private SecureInterfaceConsumer m_consumer = null;
private TaskCompletionSource m_authenticateClicked = null;
private Visibility m_authVisibility = Visibility.Collapsed;
@@ -38,7 +40,7 @@ class Scenario1ViewModel : INotifyPropertyChanged
private bool m_isCredentialsRequested = false;
private bool m_isUpperCaseEnabled = false;
private bool m_callSetProperty = true;
- private string m_key = "";
+ private string m_key = string.Empty;
public Scenario1ViewModel()
{
@@ -180,7 +182,7 @@ private void Start()
m_busAttachment.CredentialsRequested += BusAttachment_CredentialsRequested;
// Initialize a watcher object to listen for about interfaces.
- m_watcher = new SecureInterfaceWatcher(m_busAttachment);
+ m_watcher = AllJoynBusAttachment.GetWatcher(new List { "com.microsoft.Samples.SecureInterface" });
// Subscribing to the added event that will be raised whenever a producer for this service is found.
m_watcher.Added += Watcher_Added;
@@ -292,10 +294,10 @@ private async void BusAttachment_CredentialsRequested(AllJoynBusAttachment sende
credentialsDeferral.Complete();
}
- private async void Watcher_Added(SecureInterfaceWatcher sender, AllJoynServiceInfo args)
+ private async void Watcher_Added(DeviceWatcher sender, DeviceInformation args)
{
// Optional - Get the About data of the producer.
- AllJoynAboutDataView aboutData = await AllJoynAboutDataView.GetDataBySessionPortAsync(args.UniqueName, m_busAttachment, args.SessionPort);
+ AllJoynAboutDataView aboutData = await m_busAttachment.GetAboutDataAsync(await AllJoynServiceInfo.FromIdAsync(args.Id));
// Check to see if device name is populated in the about data, since device name is not a mandatory field.
if (string.IsNullOrEmpty(aboutData.DeviceName))
@@ -307,16 +309,14 @@ private async void Watcher_Added(SecureInterfaceWatcher sender, AllJoynServiceIn
UpdateStatusAsync(string.Format("Found {0} on {1} from manufacturer: {2}. Connecting...", aboutData.AppName, aboutData.DeviceName, aboutData.Manufacturer), NotifyType.StatusMessage);
}
- // Attempt to join the session when a producer is discovered.
- SecureInterfaceJoinSessionResult joinSessionResult = await SecureInterfaceConsumer.JoinSessionAsync(args, sender);
-
- if (joinSessionResult.Status == AllJoynStatus.Ok)
+ DisposeConsumer();
+ UpdateStatusAsync("Joining session...", NotifyType.StatusMessage);
+ m_consumer = await SecureInterfaceConsumer.FromIdAsync(args.Id, m_busAttachment);
+ if (m_consumer != null)
{
- DisposeConsumer();
- m_consumer = joinSessionResult.Consumer;
m_consumer.IsUpperCaseEnabledChanged += Consumer_IsUpperCaseEnabledChanged;
m_consumer.Signals.TextSentReceived += Signals_TextSentReceived;
- m_consumer.SessionLost += Consumer_SessionLost;
+ m_consumer.Session.Lost += Consumer_SessionLost;
// At the time of connection, the request credentials callback not being invoked is an
// indication that the consumer and producer are already authenticated from a previous session.
@@ -341,11 +341,11 @@ private async void Watcher_Added(SecureInterfaceWatcher sender, AllJoynServiceIn
}
else
{
- UpdateStatusAsync(string.Format("Attempt to connect failed with AllJoyn error: 0x{0:X}.", joinSessionResult.Status), NotifyType.ErrorMessage);
+ UpdateStatusAsync("Attempt to join session failed.", NotifyType.ErrorMessage);
}
}
- private void Consumer_SessionLost(SecureInterfaceConsumer sender, AllJoynSessionLostEventArgs args)
+ private void Consumer_SessionLost(AllJoynSession sender, AllJoynSessionLostEventArgs args)
{
UpdateStatusAsync(string.Format("AllJoyn session with the producer lost due to {0}.", args.Reason.ToString()), NotifyType.StatusMessage);
ConsumerOptionsVisibility = Visibility.Collapsed;
@@ -407,7 +407,7 @@ private void DisposeConsumer()
{
if (m_consumer != null)
{
- m_consumer.SessionLost -= Consumer_SessionLost;
+ m_consumer.Session.Lost -= Consumer_SessionLost;
m_consumer.Signals.TextSentReceived -= Signals_TextSentReceived;
m_consumer.IsUpperCaseEnabledChanged -= Consumer_IsUpperCaseEnabledChanged;
m_consumer.Dispose();
@@ -421,7 +421,6 @@ private void DisposeWatcher()
{
m_watcher.Added -= Watcher_Added;
m_watcher.Stop();
- m_watcher.Dispose();
m_watcher = null;
}
}
diff --git a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario2ViewModel.cs b/Samples/AllJoyn/ConsumerExperiences/cs/Scenario2ViewModel.cs
index c63cde8c0e..886563aa25 100644
--- a/Samples/AllJoyn/ConsumerExperiences/cs/Scenario2ViewModel.cs
+++ b/Samples/AllJoyn/ConsumerExperiences/cs/Scenario2ViewModel.cs
@@ -20,6 +20,7 @@
using System.Threading.Tasks;
using System.Windows.Input;
using Windows.Devices.AllJoyn;
+using Windows.Devices.Enumeration;
using Windows.Devices.WiFi;
using Windows.Networking.Connectivity;
using Windows.Security.Credentials;
@@ -62,7 +63,7 @@ class Scenario2ViewModel : INotifyPropertyChanged
private bool m_showOnboardeeSsidList = true;
private bool m_showOnboarderSsidList = false;
private AllJoynBusAttachment m_busAttachment = null;
- private OnboardingWatcher m_watcher = null;
+ private DeviceWatcher m_watcher = null;
private OnboardingConsumer m_consumer = null;
private OnboardingAuthenticationType m_selectedAuthType = OnboardingAuthenticationType.Any;
private TaskCompletionSource m_authenticateClicked = null;
@@ -692,7 +693,7 @@ private void ScanForOnboardingInterfaces()
m_busAttachment.AuthenticationMechanisms.Add(AllJoynAuthenticationMechanism.EcdheSpeke);
m_busAttachment.AuthenticationComplete += BusAttachment_AuthenticationComplete;
m_busAttachment.CredentialsRequested += BusAttachment_CredentialsRequested;
- m_watcher = new OnboardingWatcher(m_busAttachment);
+ m_watcher = AllJoynBusAttachment.GetWatcher(new List { "org.alljoyn.Onboarding" });
m_watcher.Added += Watcher_Added;
UpdateStatusAsync("Searching for onboarding interface...", NotifyType.StatusMessage);
m_watcher.Start();
@@ -756,7 +757,7 @@ private async void BusAttachment_CredentialsRequested(AllJoynBusAttachment sende
credentialsDeferral.Complete();
}
- private async void Watcher_Added(OnboardingWatcher sender, AllJoynServiceInfo args)
+ private async void Watcher_Added(DeviceWatcher sender, DeviceInformation args)
{
// This demo supports a single onboarding producer, if there are multiple onboarding producers found, then they are ignored.
// Another approach would be to create a list of all producers found and then allow the user to choose the one they want
@@ -766,25 +767,22 @@ private async void Watcher_Added(OnboardingWatcher sender, AllJoynServiceInfo ar
return;
}
+ DisposeConsumer();
UpdateStatusAsync("Joining session...", NotifyType.StatusMessage);
+ m_consumer = await OnboardingConsumer.FromIdAsync(args.Id, m_busAttachment);
- OnboardingJoinSessionResult joinSessionResult = await OnboardingConsumer.JoinSessionAsync(args, sender);
- if (joinSessionResult.Status == AllJoynStatus.Ok)
+ if (m_consumer != null)
{
- UpdateStatusAsync("Session Joined.", NotifyType.ErrorMessage);
- DisposeConsumer();
- m_consumer = joinSessionResult.Consumer;
- m_consumer.SessionLost += Consumer_SessionLost;
-
+ m_consumer.Session.Lost += Consumer_SessionLost;
GetOnboardeeNetworkListAsync();
}
else
{
- UpdateStatusAsync(string.Format("Attempt to join session failed with AllJoyn error: 0x{0:X}.", joinSessionResult.Status), NotifyType.ErrorMessage);
+ UpdateStatusAsync("Attempt to join session failed.", NotifyType.ErrorMessage);
}
}
- private void Consumer_SessionLost(OnboardingConsumer sender, AllJoynSessionLostEventArgs args)
+ private void Consumer_SessionLost(AllJoynSession sender, AllJoynSessionLostEventArgs args)
{
UpdateStatusAsync(string.Format("AllJoyn session with the onboardee lost due to {0}.", args.Reason.ToString()), NotifyType.StatusMessage);
DisposeConsumer();
@@ -987,7 +985,7 @@ private void DisposeConsumer()
{
if (m_consumer != null)
{
- m_consumer.SessionLost -= Consumer_SessionLost;
+ m_consumer.Session.Lost -= Consumer_SessionLost;
m_consumer.Dispose();
m_consumer = null;
}
@@ -999,7 +997,6 @@ private void DisposeWatcher()
{
m_watcher.Added -= Watcher_Added;
m_watcher.Stop();
- m_watcher.Dispose();
m_watcher = null;
}
}
diff --git a/Samples/AllJoyn/ConsumerExperiences/js/js/scenario1.js b/Samples/AllJoyn/ConsumerExperiences/js/js/scenario1.js
index 960a9fb15f..131e9e67f5 100644
--- a/Samples/AllJoyn/ConsumerExperiences/js/js/scenario1.js
+++ b/Samples/AllJoyn/ConsumerExperiences/js/js/scenario1.js
@@ -55,7 +55,7 @@
busAttachment.oncredentialsrequested = credentialsRequestedHandler;
// Initialize a watcher object to listen for about interfaces.
- watcher = new secureInterface.SecureInterfaceWatcher(busAttachment);
+ watcher = new allJoyn.AllJoynBusAttachment.getWatcher(["com.microsoft.Samples.SecureInterface"]);
// Subscribing to the added event that will be raised whenever a producer for this service is found.
watcher.onadded = watcherAddedHandler;
@@ -113,47 +113,51 @@
function watcherAddedHandler(args) {
// Optional - Get the About data of the producer.
- allJoyn.AllJoynAboutDataView.getDataBySessionPortAsync(args.detail[0].uniqueName, busAttachment, args.detail[0].sessionPort)
- .then(function (aboutData) {
- if (aboutData != null) {
- // Check to see if device name is populated in the about data, since device name is not a mandatory field.
- if (aboutData.deviceName != null) {
- reportStatus("Found " + aboutData.appName + " on " + aboutData.deviceName + " from manufacturer: " + aboutData.manufacturer + ". Connecting...");
- } else {
- reportStatus("Found " + aboutData.appName + " from manufacturer: " + aboutData.manufacturer + ". Connecting...");
- }
- } else {
- reportError("Unable to get About data.");
- }
- })
- .then(function () {
- // Attempt to join the session when a producer is discovered.
- secureInterface.SecureInterfaceConsumer.joinSessionAsync(args, watcher)
- .then(function (joinSessionResult) {
- if (joinSessionResult.status === allJoyn.AllJoynStatus.ok) {
- disposeConsumer();
- consumer = joinSessionResult.consumer;
- consumer.onisuppercaseenabledchanged = isUpperCaseEnabledChangedHandler;
- consumer.signals.ontextsentreceived = textSentReceivedHandler;
- consumer.onsessionlost = sessionLostHandler;
-
- // At the time of connection, the request credentials callback not being invoked is an
- // indication that the consumer and producer are already authenticated from a previous session.
- if (!isCredentialsRequested) {
- reportStatus("Connected and already authenticated from previous session.");
- isUpperCaseEnabledChangedHandler();
+ allJoyn.AllJoynServiceInfo.fromIdAsync(args.id)
+ .then(function (alljoynServiceInfo) {
+ busAttachment.getAboutDataAsync(alljoynServiceInfo)
+ .then(function (aboutData) {
+ if (aboutData != null) {
+ // Check to see if device name is populated in the about data, since device name is not a mandatory field.
+ if (aboutData.deviceName != null) {
+ reportStatus("Found " + aboutData.appName + " on " + aboutData.deviceName + " from manufacturer: " + aboutData.manufacturer + ". Connecting...");
} else {
- if (isAuthenticated) {
- reportStatus("Connected with authentication.");
- isUpperCaseEnabledChangedHandler();
- } else {
- reportError("Connected but authentication failed.");
- }
+ reportStatus("Found " + aboutData.appName + " from manufacturer: " + aboutData.manufacturer + ". Connecting...");
}
- consumerOptions.style.display = "block";
} else {
- reportError("Attempt to connect failed with AllJoyn error: 0x" + joinSessionResult.status.toString(16));
+ reportError("Unable to get About data.");
}
+ })
+ .then(function () {
+ reportStatus("Joining session...");
+ // Attempt to join the session when a producer is discovered.
+ secureInterface.SecureInterfaceConsumer.fromIdAsync(args.id, busAttachment)
+ .then(function (secureInterfaceConsumer) {
+ if (secureInterfaceConsumer != null) {
+ disposeConsumer();
+ consumer = secureInterfaceConsumer;
+ consumer.onisuppercaseenabledchanged = isUpperCaseEnabledChangedHandler;
+ consumer.signals.ontextsentreceived = textSentReceivedHandler;
+ consumer.session.onlost = sessionLostHandler;
+
+ // At the time of connection, the request credentials callback not being invoked is an
+ // indication that the consumer and producer are already authenticated from a previous session.
+ if (!isCredentialsRequested) {
+ reportStatus("Connected and already authenticated from previous session.");
+ isUpperCaseEnabledChangedHandler();
+ } else {
+ if (isAuthenticated) {
+ reportStatus("Connected with authentication.");
+ isUpperCaseEnabledChangedHandler();
+ } else {
+ reportError("Connected but authentication failed.");
+ }
+ }
+ consumerOptions.style.display = "block";
+ } else {
+ reportError("Attempt to join session failed.");
+ }
+ });
});
});
}
@@ -231,7 +235,7 @@
if (consumer != null) {
consumer.onisuppercaseenabledchanged = null;
consumer.signals.ontextsentreceived = null;
- consumer.onsessionlost = null;
+ consumer.session.onlost = null;
consumer.close();
consumer = null;
}
@@ -241,7 +245,6 @@
if (watcher != null) {
watcher.onadded = null;
watcher.stop();
- watcher.close();
watcher = null;
}
}
diff --git a/Samples/AllJoyn/ConsumerExperiences/js/js/scenario2.js b/Samples/AllJoyn/ConsumerExperiences/js/js/scenario2.js
index 8e48efe73e..77c9c7769d 100644
--- a/Samples/AllJoyn/ConsumerExperiences/js/js/scenario2.js
+++ b/Samples/AllJoyn/ConsumerExperiences/js/js/scenario2.js
@@ -85,7 +85,7 @@
busAttachment.authenticationMechanisms.append(allJoyn.AllJoynAuthenticationMechanism.ecdheSpeke);
busAttachment.onauthenticationcomplete = authenticationCompleteHandler;
busAttachment.oncredentialsrequested = credentialsRequestedHandler;
- watcher = new onboarding.OnboardingWatcher(busAttachment);
+ watcher = new allJoyn.AllJoynBusAttachment.getWatcher(["org.alljoyn.Onboarding"]);
watcher.onadded = watcherAddedHandler;
reportStatus("Searching for onboarding interface...");
watcher.start();
@@ -136,18 +136,18 @@
function watcherAddedHandler(args) {
reportStatus("Joining session...");
- onboarding.OnboardingConsumer.joinSessionAsync(args, watcher)
- .then(function (joinSessionResult) {
- if (joinSessionResult.status === allJoyn.AllJoynStatus.ok) {
+ onboarding.OnboardingConsumer.fromIdAsync(args.id, busAttachment)
+ .then(function (onboardingConsumer) {
+ if (onboardingConsumer != null) {
disposeConsumer();
- consumer = joinSessionResult.consumer;
- consumer.onsessionlost = sessionLostHandler;
+ consumer = onboardingConsumer;
+ consumer.session.onlost = sessionLostHandler;
if (!isCredentialRequested || isAuthenticated) {
getOnboardeeNetworkList();
}
} else {
- reportError("Attempt to join session failed with AllJoyn error: 0x" + joinSessionResult.status.toString(16));
+ reportError("Attempt to join session failed.");
}
});
}
@@ -446,7 +446,7 @@
function disposeConsumer() {
if (consumer != null) {
- consumer.onsessionlost = null;
+ consumer.session.onlost = null;
consumer.close();
consumer = null;
}
diff --git a/Samples/AllJoyn/shared/AllJoynBusObjectManager.cpp b/Samples/AllJoyn/shared/AllJoynBusObjectManager.cpp
index 276e214bff..d0e7b15bd9 100644
--- a/Samples/AllJoyn/shared/AllJoynBusObjectManager.cpp
+++ b/Samples/AllJoyn/shared/AllJoynBusObjectManager.cpp
@@ -9,24 +9,13 @@
//
//*********************************************************
//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// Tool: AllJoynCodeGenerator.exe
+//
+// This code was generated by a tool.
//
-// This tool is located in the Windows 10 SDK and the Windows 10 AllJoyn
-// Visual Studio Extension in the Visual Studio Gallery.
-//
-// The generated code should be packaged in a Windows 10 C++/CX Runtime
-// Component which can be consumed in any UWP-supported language using
-// APIs that are available in Windows.Devices.AllJoyn.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
-// Using AllJoynCodeGenerator - Invoke the following command with a valid
-// Introspection XML file and a writable output directory:
-// AllJoynCodeGenerator -i -o
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
//
//-----------------------------------------------------------------------------
#include "pch.h"
diff --git a/Samples/AllJoyn/shared/AllJoynBusObjectManager.h b/Samples/AllJoyn/shared/AllJoynBusObjectManager.h
index 776bbe6e7b..95c287da1e 100644
--- a/Samples/AllJoyn/shared/AllJoynBusObjectManager.h
+++ b/Samples/AllJoyn/shared/AllJoynBusObjectManager.h
@@ -9,24 +9,13 @@
//
//*********************************************************
//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// Tool: AllJoynCodeGenerator.exe
+//
+// This code was generated by a tool.
//
-// This tool is located in the Windows 10 SDK and the Windows 10 AllJoyn
-// Visual Studio Extension in the Visual Studio Gallery.
-//
-// The generated code should be packaged in a Windows 10 C++/CX Runtime
-// Component which can be consumed in any UWP-supported language using
-// APIs that are available in Windows.Devices.AllJoyn.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
-// Using AllJoynCodeGenerator - Invoke the following command with a valid
-// Introspection XML file and a writable output directory:
-// AllJoynCodeGenerator -i -o
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
//
//-----------------------------------------------------------------------------
#pragma once
diff --git a/Samples/AllJoyn/shared/AllJoynHelpers.cpp b/Samples/AllJoyn/shared/AllJoynHelpers.cpp
index 771404bca0..4e72e2c239 100644
--- a/Samples/AllJoyn/shared/AllJoynHelpers.cpp
+++ b/Samples/AllJoyn/shared/AllJoynHelpers.cpp
@@ -9,24 +9,13 @@
//
//*********************************************************
//-----------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-// Tool: AllJoynCodeGenerator.exe
-//
-// This tool is located in the Windows 10 SDK and the Windows 10 AllJoyn
-// Visual Studio Extension in the Visual Studio Gallery.
+//
+// This code was generated by a tool.
//
-// The generated code should be packaged in a Windows 10 C++/CX Runtime
-// Component which can be consumed in any UWP-supported language using
-// APIs that are available in Windows.Devices.AllJoyn.
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
//
-// Using AllJoynCodeGenerator - Invoke the following command with a valid
-// Introspection XML file and a writable output directory:
-// AllJoynCodeGenerator -i -o
+// For more information, see: http://go.microsoft.com/fwlink/?LinkID=623246
//
//-----------------------------------------------------------------------------
#include "pch.h"
@@ -43,10 +32,20 @@ alljoyn_busattachment AllJoynHelpers::GetInternalBusAttachment(_In_ AllJoynBusAt
ComPtr interop;
iUnknown.As(&interop);
UINT64 win32handle;
- interop->get_Win32Handle(&win32handle);
+ (void)interop->get_Win32Handle(&win32handle);
return reinterpret_cast(win32handle);
}
+alljoyn_busobject AllJoynHelpers::GetInternalBusObject(_In_ AllJoynBusObject^ busObject)
+{
+ ComPtr