Peer Group Manager Usage Guide for iOS

hammerhappysinnΛογισμικό & κατασκευή λογ/κού

9 Νοε 2013 (πριν από 3 χρόνια και 5 μήνες)

199 εμφανίσεις

Peer Group Manager Usage Guide for iOS
HT80-BA069-1 Rev.A
April 30,2013
Submit technical questions at:
http://www.alljoyn.org/forums
The information contained in this document is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported
License;provided,that (i) any source code incorporated in this document is licensed under the BSD 3-Clause license
and (ii) this document and all information contained herein are provided on an"as-is"basis without warranty
of any kind.
Creative Commons Attribution-ShareAlike 3.0 Unported License
AllJoyn is a trademark of QualcommInnovation Center,Inc.Other product and brand names may be trademarks or
registered trademarks of their respective owners.
This technical data may be subject to U.S.and international export,re-export,or transfer ("export") laws.Diversion
contrary to U.S.and international law is strictly prohibited.
QualcommInnovation Center,Inc.
5775 Morehouse Drive
San Diego,CA 92121-1714
U.S.A.
©
2013 QualcommInnovation Center,Inc.,All rights not expressly granted are reserved.
Contents
1 Overview...........................................................................................................4
1.1 Audience............................................................................................................................4
1.2 Glossary.............................................................................................................................4
1.3 Revision history..................................................................................................................5
1.4 Related documents............................................................................................................5
2 Development Environment.............................................................................6
2.1 Required software..............................................................................................................6
2.1.1 Mac OS X 10.7 (Lion) or higher................................................................................6
2.1.2 Homebrew (version 0.9.4 or higher).........................................................................6
2.1.3 Git (version 1.7.12.4 or higher).................................................................................6
2.1.4 Appledoc (version 2.1 or higher)..............................................................................6
2.1.5 OpenSSL Source (version 1.0.1c or higher)............................................................6
2.1.6 SQLCipher Project for OpenSSL..............................................................................7
2.1.7 AllJoyn OSX/iOS SDK (version 3.2 or higher)..........................................................7
2.1.8 PeerGroupManager Module (version 2.0 or higher).................................................7
2.1.9 Xcode 4 (or higher)...................................................................................................7
2.2 Xcode configuration...........................................................................................................8
3 Usage..............................................................................................................10
3.1 Building the PeerGroupManager.....................................................................................10
3.1.1 Building the PeerGroupManager module library....................................................10
3.1.2 Running the PeerGroupManager unit tests............................................................10
3.1.3 Regenerating the API documentation....................................................................11
3.1.4 Building the PeerGroupManagerCodeGenerator utility..........................................11
3.1.5 Running the PeerGroupManagerApp sample........................................................12
3.2 Adding the PeerGroupManager to your application.........................................................14
3.2.1 Adding the PeerGroupManager subprojects..........................................................14
3.2.2 Configuring the application targets.........................................................................17
3.2.3 Setting search paths...............................................................................................21
3.2.4 Setting other compiler settings...............................................................................23
3.2.5 Configuring the code generator target....................................................................24
4 APIs.................................................................................................................28
QualcommInnovationCenter,Inc.iiHT80-BA069-1Rev.A
MAY CONTAIN U.S.AND INTERNATIONALEXPORTCONTROLLEDINFORMATION
5 Sample Walkthrough.....................................................................................29
5.1 Define the bus interfaces.................................................................................................29
5.2 Implement the bus interfaces...........................................................................................30
5.3 Declare a PeerGroupManager member variable.............................................................32
5.4 Connect to the AllJoyn bus..............................................................................................33
5.5 Add a PGMPeerGroupDelegate (Optional).....................................................................33
5.6 Registering signal handlers..............................................................................................34
5.7 Creating a group..............................................................................................................34
5.8 Destroying a group...........................................................................................................35
5.9 Joining a group................................................................................................................35
5.10 Leaving a group.............................................................................................................36
5.11 Making remote method calls..........................................................................................36
5.12 Sending signals..............................................................................................................37
5.13 Cleaning up....................................................................................................................37
5.14 Registering modules......................................................................................................38
6 Diagrams........................................................................................................40
6.1 General flow.....................................................................................................................40
6.2 Advertisements................................................................................................................40
Figures
Figure 1:Peer Group Manager general flow.................................................................................40
Figure 2:Construction of an Advertisement..................................................................................41
Tables
Table 1:Glossary terms..................................................................................................................4
Table 2:Revision History.................................................................................................................5
Table 3:Related documents............................................................................................................5
QualcommInnovation Center,Inc.iiiHT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for
iOS
1 Overview
The Peer Group Manager is a software module that provides application developers with
an easy entry point into peer-to-peer programming using AllJoyn

.A peer group is simply
an established connection between peers that allows themto communicate over AllJoyn.
With this module,developers can use AllJoyn with minimumknowledge of AllJoyn concepts,
which is great for rapid prototyping.The Peer Group Manager provides a mapping between
high-level AllJoyn concepts and underlying implementation details abstracting out some
of the more subtle aspects that are not always relevant to new AllJoyn developers.It also
encapsulates a lot of boilerplate AllJoyn code for typical applications,including setting
default parameters,enforcing advertisement naming conventions,and making the code
simpler and cleaner.This component only covers common use cases for typical AllJoyn
applications,so if your project is advanced in nature,then this component might not be
right for you.
1.1 Audience
This guide will be helpful to iOS developers who want an easy way to get started using the
AllJoyn peer-to-peer software development framework.This guide assumes some familiarity
with AllJoyn,Objective-C programming,and the Xcode development environment.
1.2 Glossary
Table 1:Glossary terms
DefinitionTerm
Advertised Name
■ Group prefix + session port + group name.
■ The session port is automatically assigned when creating the session and is
preceded by"sp"in the advertisement.

Example:org.alljoyn.chat.sp42.chatroom1
Group Prefix
■ The prefix of the advertised name that will be prepended to all group names
■ Note:Your PeerGroupManager will only be able to communicate with other
PeerGroupManagers that use the same group prefix.
■ Example:org.alljoyn.chat
Group Name
■ The suffix of the advertised name that comes after the group prefix
■ Example:chatroom1
Peer Group
■ An established connection between peers that allows themto communicate
over AllJoyn
■ Multiple peer groups can exist at the same time
QualcommInnovation Center,Inc.4HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
DefinitionTerm
■ Applications may be a part of more than one group at any given time
Peer ID
■ The unique name of the BusAttachment
■ You can obtain your own Peer Id fromthe getMyPeerId method
■ You can obtain the Peer Id of a peer fromthe following places:
■ You can obtain the Peer Id of a peer fromthe following places:
❒ getIdsOfPeersInGroup:() when participating in a group with the
peer

didAddPeer:fromthe PGMPeerGroupDelegate

didRemovePeer:fromthe PGMPeerGroupDelegate

getHostPeerIdOfGroup:
1.3 Revision history
Table 2 provides the revision history for this document.
Table 2:Revision History
DescriptionDateVersion
Initial releaseApril 2013A
1.4 Related documents
Table 3 is a list of supplemental documents that relate to the information in this guide.
Table 3:Related documents
TitleLocation
Introduction to AllJoynhttp://www.alljoyn.org
AllJoyn Programming Guide for the Objective-C
Language
http://www.alljoyn.org
Configuring the Build Environment (iOS and OS X)http://www.alljoyn.org
QualcommInnovation Center,Inc.5HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Overview
2 Development Environment
2.1 Required software
To develop applications using the PeerGroupManager,download and install the software
listed in the following subsections.
Note The approach that this document recommends for setting up third-party software
differs in some places fromthe approach recommended for other AllJoyn
projects.
2.1.1 Mac OS X 10.7 (Lion) or higher
■ Fromthe App Store application,upgrade OS X to the latest version.
2.1.2 Homebrew (version 0.9.4 or higher)
Use Homebrew to deploy git and appledoc.
■ To install Homebrew,follow the instructions at:http://mxcl.github.com/homebrew/
2.1.3 Git (version 1.7.12.4 or higher)
Use Git for source control.
■ Open a terminal window and type the command:
brew install git
2.1.4 Appledoc (version 2.1 or higher)
The appledoc tool generates documentation for the PeerGroupManager software.For more
information on appledoc,see:http://gentlebytes.com/appledoc/.
■ Open a terminal window and type the command:
brew install appledoc
2.1.5 OpenSSL Source (version 1.0.1c or higher)
OpenSSL is an open source toolkit for implementing the Secure Sockets Layer (SSL v2/v3)
and Transport Layer Security (TLS v1).Installing OpenSSL is necessary for iOS
development only.If you are only targeting OS X,you can skip this section.
1.Download the compressed archive file containing the OpenSSL files from:
http://www.openssl.org/
QualcommInnovation Center,Inc.6HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
2.Find or create a convenient target folder for the extracted OpenSSL files (e.g.,
~/Development/OpenSSL)
3.Copy the compressed archive file fromthe Downloads folder to the target folder.
4.Double-click to extract the files.
2.1.6 SQLCipher Project for OpenSSL
The SQLCipher Project for OpenSSL contains an Xcode project template to build the
OpenSSL libraries iOS.For more information on this tool,see:
http://sqlcipher.net/ios-tutorial/.
1.Find or create a convenient target folder for the SQLCipher project files (e.g.,
~/Development/SQLCipher).
2.Open a terminal window and type the following two commands:
cd <path_to_SQLCipher_target_folder>
git clone https://github.com/sqlcipher/openssl-xcode.git
2.1.7 AllJoyn OSX/iOS SDK (version 3.2 or higher)
AllJoyn is the library which provides the peer-to-peer communications infrastructure needed
by the PeerGroupManager module.
1.Download the compressed archive file containing the AllJoyn SDK files from:
http://www.alljoyn.org/docs-and-downloads.
2.Find or create a convenient target folder for the AllJoyn SDK files (e.g.,
~/Development/AllJoynSDKs).
3.Copy the compressed archive file fromthe Downloads folder to the target folder.
4.Double-click to extract the files.
2.1.8 PeerGroupManager Module (version 2.0 or higher)
The PeerGroupManager module provides Objective-C classes that make it easier to write
peer-to-peer AllJoyn applications.
1.Find or create a convenient target folder to hold files for AllJoyn modules such as the
PeerGroupManager (e.g.,~/Development/AllJoynModules).
2.Open a terminal window and type the following two commands:
cd <path_to_PeerGroupManager_target_folder>
git clone git://github.com/alljoyn/PeerGroupManager.git
2.1.9 Xcode 4 (or higher)
Xcode is the IDE used to build applications for OS X and iOS.
QualcommInnovation Center,Inc.7HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Development Environment
■ Fromthe App Store application,download and install Xcode.
2.2 Xcode configuration
The PeerGroupManager project references several build variables that must be defined
in Xcode.
1.Open Xcode.
2.Select the Xcode > Preferences menu item
3.Click on the Locations icon.
4.Click on the Source Trees tab.
Tip In the remaining steps,if the edit cursor is in the Path cell of a table row,
you can enter a path by dragging a target folder fromFinder into the cell.
Tip In the remaining steps,the last folder in the path you enter for each variable
should match (except for version numbers) the last folder in the
corresponding path shown in the example screen capture.
5.Click the “+” button in the lower left corner to add a new blank row to the table.
6.In the newrow,enter “OPENSSL_SRC”,for the Setting Name,“OpenSSL Source” for
the Display Name,and for Path enter the full path to the target OpenSSL folder you
created in OpenSSL Source (version 1.0.1c or higher).
7.Click the “+” button again.
8.In the new row,enter “OPENSSL_PROJ”,for the Setting Name,“OpenSSL Project”
for the Display Name,and for Path enter the full path to the target SQLCipher folder
you created in SQLCipher Project for OpenSSL.
9.Click the “+” button again.
10.In the newrow,enter “ALLJOYN_HOME”,for the Setting Name,“AllJoyn SDK” for the
Display Name,and for Path enter the full path to the target AllJoyn SDK folder you
created in PeerGroupManager Module (version 2.0 or higher).
QualcommInnovation Center,Inc.8HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Development Environment
11.Click the “+” button again.
12.In the new row,enter “PGM_HOME”,for the Setting Name,“PeerGroupManager
Project” for the Display Name,and for Path enter the full path to the target
PeerGroupManager module folder you created in Xcode 4 (or higher).
QualcommInnovation Center,Inc.9HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Development Environment
3 Usage
3.1 Building the PeerGroupManager
You can open and build the various PeerGroupManager projects in order to check the build
process,generate the API documentation,run unit tests,or run the included sample app.
To incorporate the PeerGroupManager into your own projects,please refer to Adding the
PeerGroupManager to your application.
3.1.1 Building the PeerGroupManager module library
1.Navigate in Finder to the PeerGroupManager target folder,and then to the
ObjC/PeerGroupManager_iOS subfolder.
2.Double-click on the PeerGroupManager_iOS.xcodeproj itemto launch Xcode.
3.To build the PeerGroupManager module,select the PeerGroupManager_iOSscheme
and the desired platform.The active scheme is controlled by a selection box located
in the upper left-hand corner of the Xcode user interface,as shown here.
4.Once you select a scheme and a platformto build against,select Product > Build from
the Xcode menu.
5.Once the build completes successfully,you can expand the Products folder at the
bottomof the project navigator windowto reveal the newly created PeerGroupManager
binary.
3.1.2 Running the PeerGroupManager unit tests
The PeerGroupManager project contains the test code written to ensure the
PeerGroupManager functions correctly.If you intend to modify the PeerGroupManager
QualcommInnovation Center,Inc.10HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
source code but want to preserve its original behavior,running these tests can help verify
that the behavior has not changed.Please note,however,that passing the unit tests does
not necessarily mean that your changes will function correctly.
1.Navigate in Finder to the PeerGroupManager target folder,and then to the
ObjC/PeerGroupManager_iOS subfolder.
2.Double-click on the PeerGroupManager_iOS.xcodeproj itemto launch Xcode.
3.To build the PeerGroupManager module,select the PeerGroupManager_iOSscheme
with a simulator for the platform.
4.Once you select a scheme and a simulator,select Product > Test fromthe Xcode
menu.
Note The unit tests can only be run with a simulator as a target platform.They cannot
be run on an actual device.
3.1.3 Regenerating the API documentation
1.Navigate in Finder to the PeerGroupManager target folder,and then to the
ObjC/PeerGroupManager_iOS subfolder.
2.Double-click on the PeerGroupManager_iOS.xcodeproj itemto launch Xcode.
3.To build the PeerGroupManager API documentation,select the API Documentation
_iOS (PeerGroupManager_iOS project) scheme with any target,as shown here.
4.Once you select the scheme,select Product > Build fromthe Xcode menu.
5.The generated API documentation will be located under the PeerGroupManager target
folder in a ObjC/PeerGroupManager_iOS/doc subfolder.
3.1.4 Building the PeerGroupManagerCodeGenerator utility
The PeerGroupManagerCodeGenerator is a utility that will generate most of the boilerplate
code for your service objects.It is distributed with the PeerGroupManager module,but has
its own project.
QualcommInnovation Center,Inc.11HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
Normally,the code generator is invoked by a build target that is included in another project
(see Configuring the code generator target for information on how to create such a build
target),so you usually do not need to open and build the code generator project directly.
The instructions in this section are only provided for completeness.
Note The PeerGroupManagerCodeGenerator is different than the code generator
distributed with the AllJoyn OSX/iOS SDK.They both take the same interface
specification XML file,but the PeerGroupManagerCodeGenerator emits code
that is customized to work with the PeerGroupManager module.You should
only use the PeerGroupManagerCodeGenerator when developing software
that will use the PeerGroupManager module.For more information on how to
create the XML file that defines the bus interface,please see the AllJoyn
Programming Guide for the Objective-C Language.
1.Navigate in Finder to the PeerGroupManager target folder,and then to the
ObjC/PeerGroupManagerCodeGenerator subfolder.
2.Double-click on the PeerGroupManagerCodeGenerator.xcodeproj itemto launch
Xcode.
3.The PeerGroupManagerCodeGenerator only has one scheme,named
PeerGroupManagerCodeGenerator,which should automatically be the active scheme.
4.Select Product > Build fromthe Xcode menu.
5.The generated application binary and template XSL files will be created under the
PeerGroupManager target folder in a ObjC/PeerGroupManagerCodeGenerator/bin
subfolder.
3.1.5 Running the PeerGroupManagerApp sample
The PeerGroupManagerApp is a sample programthat demonstrates how to use the
PeerGroupManager module.It is distributed with the PeerGroupManager module,but has
its own project.
Note The PeerGroupManagerApp project includes both the PeerGroupManager
module and the PeerGroupManagerCodeGenerator as subprojects.Because
of this,Xcode will not allow you to have these other projects open at the same
time.
Note In order to run iOS applications locally on a device,you must be registered as
an Apple developer and obtain a developer certificate.For more information
about how to become an Apple developer,visit:http://developer.apple.com.
1.Close the PeerGroupManager module project and the
PeerGroupManagerCodeGenerator project if either is open in Xcode.
2.Navigate in Finder to the PeerGroupManager target folder,and then to the
samples/PeerGroupManagerApp subfolder.
3.Double-click on the PeerGroupManager_iOS.xcodeproj itemto launch Xcode.
QualcommInnovation Center,Inc.12HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
4.To run the PeerGroupManagerApp,select the PeerGroupManagerApp scheme with
the desired target platform,as shown below.
5.Once you select the scheme,select Product > Run fromthe Xcode menu.
6.The application will be built and launched on the specified platform.On the iPhone 6.1
simulator,it appears as shown below.
If you have multiple iOS devices that are connected to your development systemand on
the same WiFi network,you can connect each one to Xcode and launch the app on each
device.Once running,they should be able to communicate over AllJoyn and join each
other’s peer groups.
QualcommInnovation Center,Inc.13HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
3.2 Adding the PeerGroupManager to your application
Once you have created your own project in Xcode,you can easily enable peer-to-peer
communications over AllJoyn by adding the PeerGroupManager module to it.Although
there are many ways you could reference the PeerGroupManager library in your iOS
application,the suggested method is to add the PeerGroupManager library and code
generator as subprojects of your application.The following steps describe howto configure
your application’s project to achieve this.
Note These same steps have already been done for the PeerGroupManagerApp
sample application,so you can use that project as a reference for the changes
you are making to your own application’s project.
3.2.1 Adding the PeerGroupManager subprojects
To add the PeerGroupManager library and the PeerGroupManagerCodeGenerator projects
as subprojects of your application,performthe following steps:
1.Right-click on the top level project node in the Project Navigator.
2.Select Add Files to <Project Name>.
QualcommInnovation Center,Inc.14HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
3.Navigate to the folder containing the PeerGroupManager repository you retrieved using
Git (see Git (version 1.7.12.4 or higher)),and select the following item:
<path_to_PeerGroupManager_target_folder>/ObjC/PeerGroupManager_iOS/
PeerGroupManager_iOS.xcodeproj
QualcommInnovation Center,Inc.15HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
4.Uncheck the box that says Copy items into destination group’s folder (if needed).
5.Click Add.
6.Next,right-click on the top level project node in the Project Navigator again.
7.Select Add Files to <Project Name>.
8.Navigate back to the folder containing the PeerGroupManager repository,and
double-click the following item:
<path_to_PeerGroupManager_target_folder>/ObjC/PeerGroupManagerCodeGenerator/
PeerGroupManagerCodeGenerator.xcodeproj
QualcommInnovation Center,Inc.16HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
You should now see the PeerGroupManager library and the
PeerGroupManagerCodeGenerator listed as subprojects in your project,as shown
below.
9.Click the PeerGroupManager_iOS.xcodeproj subproject node in the Project Navigator,
and in the File Inspector (on the right-hand side of the Xcode window),change its
location setting to Relative to PeerGroupManager.
10.Click the PeerGroupManagerCodeGenerator subproject in the Project Navigator,and
in the File Inspector (on the right-hand side of the Xcode window),change its location
setting to Relative to PeerGroupManager.
3.2.2 Configuring the application targets
Once the PeerGroupManager is a referenced as a subproject,you need to configure the
build targets for your application to be able to include the appropriate header files and link
to the appropriate binaries.
QualcommInnovation Center,Inc.17HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
Note Your application may have more than one build target.For example,in addition
to the build target for the main application,there may also be a build target for
unit tests.You will need to repeat the following steps for any target that needs
to link against the PeerGroupManager library.
1.Click your application’s top level project node in the Project Navigator.
2.Click the desired build target on the left-hand side of the Editor area.
3.Select the Build Phases tab at the top of the Editor area and expand the Target
Dependencies list.
4.Click the “+” button to add a target dependency.
5.Select PeerGroupManager_iOS and click Add.
QualcommInnovation Center,Inc.18HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
6.Expand the Link Binary with Libraries list.
7.Click the “+” button to select libraries to add.
8.Command-click the following libraries:
■ libPeerGroupManager_iOS.a
■ libcrypto.a
■ libAllJoynFramework_iOS.a
9.Click Add to add the libraries.
10.Click the “+” button again to select libraries to add.
11.In the iOS folder,find and add the following two libraries:
SystemConfiguration.framework and libstdc++.6.0.9.dylib.
12.Select the Build Settings tab and change the display options to “All” and “Combined”.
QualcommInnovation Center,Inc.19HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
13.Expand the Architectures list and find the “Architectures” build setting.
14.Click on current architecture setting and select Other to add a newarchitecture.Atable
popup opens.
15.Click the “+” button in the lower left corner of the table popup to add a newarchitecture,
and enter “armv7”.
16.Click outside of the popup to close it.
17.Set the Build Active Architecture Only to “Yes”.
18.Find the section entitled Linking and expand the settings list.
19.Find the setting Other Linker Flags and double-click in the empty space next to the
setting name.A table popup opens.
QualcommInnovation Center,Inc.20HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
20.Click the “+” button in the lower left corner of the table popup and enter “–lalljoyn”.
21.Repeat step 20 four times to enter the following linker flags:“–lajdaemon”,
“–lBundledDaemon.o”,“–lssl”,and “–lcrypto”.
22.Click outside the popup to close it.
3.2.3 Setting search paths
1.Find the section entitled Search Paths and expand the settings list.
2.Find the setting Header Search Paths.
3.Double-click in the empty space next to the Header Search Paths setting.A table
popup opens.
Note Quotes are needed around the header search path entries in steps 4 - 6.
4.Click the “+” button in the lower left corner of the table popup and enter
“$(OPENSSL_SRC)/include”.
5.Click the “+”,and enter
“$(PGM_HOME)/ObjC/PeerGroupManager_iOS/PeerGroupManager_iOS”.
QualcommInnovation Center,Inc.21HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
6.Different versions of the AllJoyn SDKmay require different header search paths.When
compiling against version 3.3 of the AllJoyn SDK,enter the following four paths using
the same process outlined in step 5:
“$(ALLJOYN_HOME)/alljoyn_core/build/darwin/$(CURRENT_ARCH)/$(PLATFORM_NAME)
/$(CONFIGURATION)/dist/cpp/inc”
“$(ALLJOYN_HOME)/alljoyn_core/build/darwin/$(CURRENT_ARCH)/$(PLATFORM_NAME)
/$(CONFIGURATION)/dist/cpp/inc/alljoyn”
“$(ALLJOYN_HOME)/alljoyn_core/build/darwin/arm/iphonesimulator
/$(CONFIGURATION)/dist/cpp/inc”
“$(ALLJOYN_HOME)/alljoyn_core/build/darwin/arm/iphonesimulator
/$(CONFIGURATION)/dist/cpp/inc/alljoyn”
When compiling against version 3.2 of the AllJoyn SDK,the following four paths are
needed:
“$(ALLJOYN_HOME)/alljoyn_core/build/darwin/$(CURRENT_ARCH)/$(PLATFORM_NAME)
/$(CONFIGURATION)/dist/inc”
“$(ALLJOYN_HOME)/alljoyn_core/build/darwin/$(CURRENT_ARCH)/$(PLATFORM_NAME)/
$(CONFIGURATION)/dist/inc/alljoyn”
“$(ALLJOYN_HOME)/alljoyn_core/build/darwin/arm/iphonesimulator/
$(CONFIGURATION)/dist/inc”
“$(ALLJOYN_HOME)/alljoyn_core/build/darwin/arm/iphonesimulator/
$(CONFIGURATION)/dist/inc/alljoyn”
If you want to easily switch between AllJoyn 3.2 and AllJoyn 3.3,include all eight header
paths.
7.Click outside the popup to close it.
8.Find the setting Library Search Paths.
9.Double-click in the empty space next to the Library Search Paths setting.A table
popup opens.
10.Click the “+” button in the lower left corner of the table popup,and enter $(inherited).
Note:Quotes are NOT needed for this particular entry.
11.Different versions of the AllJoyn SDK may require different library search paths.When
compiling against version 3.3 of the AllJoyn SDK,enter the following two paths using
QualcommInnovation Center,Inc.22HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
the same process outlined in step 10.Quotes are needed around the library search
path entries:
“$(ALLJOYN_HOME)/alljoyn_core/build/darwin/$(CURRENT_ARCH)/$(PLATFORM_NAME)
/$(CONFIGURATION)/dist/cpp/lib”
“$(ALLJOYN_HOME)/alljoyn_core/build/darwin/arm/iphonesimulator/
$(CONFIGURATION)/dist/cpp/lib”
When compiling against version 3.2 of the AllJoyn SDK,the following two paths are
needed:
“$(ALLJOYN_HOME)/alljoyn_core/build/darwin/$(CURRENT_ARCH)/$(PLATFORM_NAME)
/$(CONFIGURATION)/dist/lib”
“$(ALLJOYN_HOME)/alljoyn_core/build/darwin/arm/iphonesimulator/
$(CONFIGURATION)/dist/lib”
If you want to easily switch between AllJoyn 3.2 and AllJoyn 3.3,include all four library
paths.
12.Click outside the popup to close it.
3.2.4 Setting other compiler settings
1.Find the section entitled Apple LLVMcompiler X.X - Language and expand the
settings list.
2.Set Enable C++ Exceptions to NO.
3.Set Enable C++ Runtime Types to NO.
4.Find the Other C Flags setting and expand the list.You should see options for debug
and release.
5.Double-click in the empty space next to the Debug option.A table popup opens.
6.Click the “+” button in the lower left corner of the table popup,and enter
“-DQCC_OS_GROUP_POSIX”.
7.Repeat step 40 while entering “-DQCC_OS_DARWIN”.
QualcommInnovation Center,Inc.23HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
8.Click outside the popup to close it.
9.Double-click in the empty space next to the Release option.A table popup opens.
10.Click the “+”button in the lower left corner of the table popup,and enter
“-DQCC_OS_GROUP_POSIX”.
11.Repeat step 10 two times for the entries “-DQCC_OS_DARWIN” and
“-DNS_BLOCK_ASSERTIONS=1”.
12.Click outside the popup to close it.
3.2.5 Configuring the code generator target
You can optionally add a build target to your application’s project that invokes the
PeerGroupManagerCodeGenerator on your bus interface specification file.This will allow
you to easily regenerate your bus objects whenever the specification changes.
Note The PeerGroupManagerCodeGenerator does not expect any modifications to
be made to its output files,so when it runs it overwrites themwithout prompting
for confirmation.This is by design,and normally does not cause problems,
because the emitted classes are intended to be extended in separate source
files in order to implement the bus interface functionality.However,if for some
reason you have edited the PeerGroupManagerCodeGenerator output files,
you would not want it to run accidentally,and so you might not want to create
the code generator target in your project.
To add a code generation build target,performthe following steps:
1.Click your application’s top level project node in the Project Navigator.
2.Click Add Target in the lower left corner of the Editor area.
QualcommInnovation Center,Inc.24HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
3.Select Other under the OS X list on the left side of the dialog,choose the External
Build Systemtemplate for your new target,and click Next.
4.Type “Generate Bus Interface Source” in the Product Name field,and click Finish.
QualcommInnovation Center,Inc.25HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
5.Select the Generate Bus Interface Source target,and click the Info tab in the Editor
area.
6.In the Arguments field,enter the following text (all on one line):
-c"$(PGM_HOME)/ObjC/PeerGroupManagerCodeGenerator/bin
/PeerGroupManagerCodeGenerator$(SOURCE_ROOT)/<path_to_your_xml_file>
<OutputFilenameBase>"
Where <path_to_your_xml_file> is the relative path within your project to the XML
file that describes your bus interface,and <OutputFilenameBase> is the base filename
that the code generator will use for the emitted files.
7.To run the PeerGroupManagerCodeGenerator,select the Generate Bus Interface
Source scheme with any target,as shown here.
QualcommInnovation Center,Inc.26HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
8.Once you select the scheme,select Product > Build fromthe Xcode menu.The
generated source files will be created in the same folder as the XML file.
QualcommInnovation Center,Inc.27HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Usage
4 APIs
For the APIs,please refer to the appledoc files located in the
ObjC/PeerGroupManager_iOS/doc subdirectory of the PeerGroupManager project.If these
files have not yet been generated,please see Regenerating the API documentation
QualcommInnovation Center,Inc.28HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
5 Sample Walkthrough
This is an example of how a typical iOS application might use the PeerGroupManager
module.The code snippets used in the following examples are fromthe
PeerGroupManagerApp sample application.
5.1 Define the bus interfaces
Define the AllJoyn interfaces.In this example,there are two interfaces.One interface is
called SimpleService,and is composed of a signal named Ping.It is defined in the XML
file named SimpleObject.xml,which has the following contents:
<xml>
<node name="/SimpleService">
<annotation name="org.alljoyn.lang.objc"value="SimpleObject"/>
<interface name="org.alljoyn.bus.samples.simple.SimpleInterface">
<annotation name="org.alljoyn.lang.objc"
value="SimpleDelegate"/>
<signal name="Ping">
<arg name="Str"type="s">
<annotation name="org.alljoyn.lang.objc"
value="PingString:"/>
</arg>
</signal>
</interface>
</node>
</xml>
The second interface is called TestObject,and is composed of a method called Echo.It
is defined in the XML file named TestObject.xml,which has the following contents:
<xml>
<node name="org/alljoyn/TestObject">
<annotation name="org.alljoyn.lang.objc"value="TestObject"/>
<interface name="org.alljoyn.bus.samples.testInterface">
<annotation name="org.alljoyn.lang.objc"value="TestDelegate"/>
<method name="Echo">
<arg name="str"type="s"direction="in">
<annotation name="org.alljoyn.lang.objc"value="echoString:"/>
</arg>
<arg name="outStr"type="s"direction="out"/>
</method>
</interface>
QualcommInnovation Center,Inc.29HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
</node>
</xml>
Running the PeerGroupManagerCodeGenerator on these two XML files generates the
following eight source files containing the code implementing the framework for the bus
interfaces:
PGMSimpleObjectBase.h
PGMSimpleObjectBase.m
PGMSimpleObjectImpl.h
PGMSimpleObjectImpl.h
PGMTestObjectBase.h
PGMTestObjectBase.m
PGMTestObjectImpl.h
PGMTestObjectImpl.h
Once this framework is in place,the next step is to implement the functionality for the
interfaces.
5.2 Implement the bus interfaces
While the code generator utility can generate the framework needed to interface with
AllJoyn,it is up to the developer to implement the functionality behind the interface.Because
of the way the PeerGroupManagerCodeGenerator works,it is not recommended to place
any of this functionality (or any edits at all) in an emitted file.Instead,you can create
separate source and header files that extend the classes emitted by the code generator.
In the case of the PeerGroupManagerApp,these separate files are:
PGMSimpleObject.h
PGMSimpleObject.m
PGMTestObject.h
PGMTestObject.m
Since the SimpleService interface only consists of a single signal,the implementation in
the PGMSimpleObject.h and PGMSimpleObject.m files is empty.That is because when
signals are received,they trigger a signal handler to execute,so our implementation for
the Ping signal will reside in its signal handler.In this case,the signal handler is attached
to the PGMPingGroupViewController class:
@interface PGMPingGroupViewController:UIViewController <...,
SimpleDelegateSignalHandler>
...
@end
@implementation PGMPingGroupViewController
...
-(void)didReceivePingString:(NSString *)Str group:(NSString *)groupName
fromSender:(NSString *)sender
{
QualcommInnovation Center,Inc.30HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Sample Walkthrough
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setTimeStyle:NSDateFormatterMediumStyle];
[dateFormatter setDateStyle:NSDateFormatterNoStyle];
if([self.chatLogs objectForKey:groupName])
{
[[self.chatLogs objectForKey:groupName] appendString:[NSString
stringWithFormat:@"[%@] %@:%@\n",[dateFormatter
stringFromDate:[NSDate date]],sender,Str]];
}
else
{
[self.chatLogs setObject:[NSMutableString stringWithFormat:@"[%@] %@:
%@\n",[dateFormatter stringFromDate:[NSDate date]],sender,Str]
forKey:groupName];
}
if([self.selectedGroup isEqualToString:groupName])
{
//Go to the bottom of the chat log if the chat is larger than the
textview size
self.logTextView.text = [self.chatLogs objectForKey:self.selectedGroup];
CGPoint bottomOffset = CGPointMake(0,
self.logTextView.contentSize.height -
self.logTextView.bounds.size.height);
if(bottomOffset.y > 0)
{
[self.logTextView setContentOffset:bottomOffset animated:YES];
}
}
}
@end
This implementation simply adds the received ping message and some context information
to the message log in the GUI.
In contrast,the TestObject interface only consists of single method.The implementation
for bus methods is attached to an instance method in a BusObject subclass,which is
overridden in our implementation files PGMTestObject.h and PGMTestObject.m.
QualcommInnovation Center,Inc.31HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Sample Walkthrough
Note The BusObject class is defined in AllJoyn.Please refer to the AllJoyn
documentation for more details.
@interface PGMTestObjectExtension:TestObject
@end
@implementation PGMTestObjectExtension
- (NSString*)echoString:(NSString*)str fromSender:(NSString *)sender
{
NSLog(@"Echo was called on %@ by sender %@",str,sender);
return str;
}
@end
This implementation simply outputs the received echo message and some context
information to the iOS logging facility.
5.3 Declare a PeerGroupManager member variable
Declare a PGMPeerGroupManager property so that it can be used throughout your code.
In the sample app,each view class receives a PGMPeerGroupManager property through
the PGMView protocol:
@protocol PGMView <NSObject>
@property (nonatomic,strong) PGMPeerGroupManager *peerGroupManager;
@end
When a view is created,its peerGroupManager property is assigned to a copy of the
instance allocated by the PGMMainMenuViewController class.
QualcommInnovation Center,Inc.32HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Sample Walkthrough
5.4 Connect to the AllJoyn bus
Connecting your application to the AllJoyn bus is easy.Simply create your
PGMPeerGroupManager instance and the connection happens automatically.In the sample
app,the instance is created in the viewDidLoad method
viewDidLoad method
- (void)viewDidLoad
{
...
self.peerGroupManager = [[PGMPeerGroupManager alloc]
initWithGroupPrefix:@"org.alljoyn.PeerGroupManagerApp"
withPeerGroupDelegate:self
withBusObjects:nil];
...
}
5.5 Add a PGMPeerGroupDelegate (Optional)
If your application needs to know when a new peer joins a group,when a peer leaves a
group,when a new group is discovered,when a group stops advertising,or if a group
becomes disconnected,you can add a PGMPeerGroupDelegate instance to listen for these
events.The listener can be passed into the init method of the PeerGroupManager,or it
can be added via the addPeerGroupDelegate:method as shown in the code below.
PGMPeerGroupDelegates can be added at any time and you can add as many delegates
as needed.
In the sample app,the PGMListPeersViewController declares itself to be a
PGMPeerGroupDelegate to so that it can listen for the didAddPeer:,didRemovePeer:,
and groupWasLost:events in order to update the display accordingly.
- (void)viewDidLoad
{
...
[self.peerGroupManager addPeerGroupDelegate:self];
...
}
...
- (void)didAddPeer:(NSString *)peerId toGroup:(NSString *)groupName
forATotalOf:(int)numPeers
{
NSLog(@"didAddPeer with peer %@ in group %@ while selected group
is %@",peerId,groupName,self.selectedGroup);
if([self.selectedGroup isEqualToString:groupName])
{
[self.peerTableView reloadData];
}
}
QualcommInnovation Center,Inc.33HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Sample Walkthrough
- (void)didRemovePeer:(NSString *)peerId fromGroup:(NSString *)groupName
forATotalOf:(int)numPeers
{
if([self.selectedGroup isEqualToString:groupName])
{
[self.peerTableView reloadData];
}
}
- (void)groupWasLost:(NSString *)groupName
{
[self.groupTableView reloadData];
if([self.selectedGroup isEqualToString:groupName])
{
[self.peerTableView reloadData];
}
}
5.6 Registering signal handlers
If your AllJoyn interface contains any signals,then you will want to register your signal
handlers to be triggered when those signals are received.To do so,simply call the
appropriate method emitted by the code generator for your bus object,passing in a reference
to a class that contains the signal handler methods.Since the name of this method
incorporates the name of the bus interface,it will be different for different interface
specifications,but the method name will have the general format “register...SignalHandler”.
For example,in the sample app,the Simple Service interface consists of a signal,and so
the emitted PGMSimpleObject class contains a registerSimpleDelegateSignalHandler:
method.The PGMPingGroupViewController class adds itself as the signal handler in its
viewDidLoad method:
- (void)viewDidLoad
{
...
[self.simpleObject registerSimpleDelegateSignalHandler:self];
...
}
5.7 Creating a group
Creating a group is simple.You just call createGroupWithName:or createGroupWithName:
andLock:and pass in the name of the new group you wish to create.You can create as
many groups as you want given that all the group names are unique.If you try to create a
group with a name that already exists,the call will fail.
QualcommInnovation Center,Inc.34HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Sample Walkthrough
Note You are inherently a peer of your own groups so you do not need to call
joinGroupWithName:on groups you create.
In the sample app,an example of this is in the createGroupButtonPressed:method of
the PGMCreateGroupViewController class:
- (IBAction)createGroupButtonPressed:(UIButton *)sender
{
...
QStatus status = [self.peerGroupManager createGroupWithName:groupName
andLock:lock];
...
}
5.8 Destroying a group
Destroying a group is just as easy as creating a group.Simply call destroyGroupWithName:
on the group you wish to destroy.The module will only allow you to destroy groups that
you have created.One tip when allowing the user of the app to decide which group to
destroy is to call listHostedGroupNames which returns a list of groups that you have
created.In the sample app,an example of destroying a group is in the
destroySelectedGroupsButtonPressed:method of the
PGMDestroyGroupViewController class:
- (IBAction)destroySelectedGroupsButtonPressed:(UIButton *)sender
{
...
QStatus status = [self.peerGroupManager destroyGroupWithName:cell.
textLabel.text];
...
}
5.9 Joining a group
To join a group,simply call joinGroupWithName:with the desired groupName.One trick
is to call listFoundGroupNames,let the user select a group,and then call
joinGroupWithName:on the selected groupName.
QualcommInnovation Center,Inc.35HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Sample Walkthrough
In the sample app,an example of joining a group is in the
joinSelectedGroupsButtonPressed:method of the PGMJoinGroupViewController
class:
- (IBAction)joinSelectedGroupsButtonPressed:(id)sender
{
...
QStatus status = [self.peerGroupManager joinGroupWithName:cell.
textLabel.text];
...
}
5.10 Leaving a group
To leave a group,simply call leaveGroupWithName:with the desired groupName.One
trick is to call listJoinedGroupNames,let the user select a group,and then call
leaveGroupWithName:on the selected groupName.
Note You cannot leave groups that you created.To close a group you created,you
must call destroyGroupWithName:.
In the sample app,an example of leaving a group is in the
leaveSelectedGroupsButtonPressed:method of the PGMLeaveGroupViewController
class:
- (IBAction)leaveSelectedGroupsButtonPressed:(id)sender
{
...
QStatus status = [self.peerGroupManager leaveGroupWithName:cell.
textLabel.text];
...
}
5.11 Making remote method calls
Once you are participating in a group,whether you are hosting it or just joined it,you can
make remote method calls to another peer’s bus objects over that group.To do so you
need to get an interface object,which AllJoyn calls a “proxy object”,fromthe
PeerGroupManager.Once you have the proxy,you can use it to make method calls just
like any other object.
QualcommInnovation Center,Inc.36HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Sample Walkthrough
In the sample app,an example of making a remote method call is in the
echoButtonPressed:method of the PGMEchoViewController class:
- (IBAction)echoButtonPressed:(id)sender
{
...
TestObjectProxy *proxy = (TestObjectProxy *) [self.peerGroupManager
getRemoteObjectWithClassName:@"TestObjectProxy"forPeer:remotePeer
inGroup:groupName onPath:@"/org/alljoyn/TestObject"];
NSString *replyString = [proxy echoString:self.echoString.text];
...
}
5.12 Sending signals
To send a signal,you also need an interface object just like when you make a remote
method call.However,instead of invoking a method on a remote peer in the group,you
are sending a signal fromyour own bus object to the group or to a specific peer within the
group.
In the sample app,an example of sending a signal is in the sendButtonPressed:method
of the PGMPingGroupViewController class:
- (IBAction)sendButtonPressed:(id)sender
{
...
[self.simpleObject sendPingString:self.pingTextView.text
group:self.selectedGroup toDestination:nil];
...
}
In the example above we are sending a broadcast signal to all peers within the group.If
we were to call the sendPingString:method with a peer ID for the destination instead
of nil,then the signal would be directed only to that peer.
5.13 Cleaning up
When your application is done and is about to exit,you want to clean up all of your AllJoyn
resources to prevent any resource leaks.To do this,simply call cleanup:and you’re set.
The cleanup:method will leave all joined sessions,destroy all hosted sessions,unregister
your bus objects and signal handlers,and finally disconnect your bus attachment fromthe
AllJoyn bus.
QualcommInnovation Center,Inc.37HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Sample Walkthrough
In the sample app,this is triggered by the applicationWillTerminate:method of the
PGMAppDelegate class:
- (void)applicationWillTerminate:(UIApplication *)application
{
[self.mainMenu cleanup];
}
Which calls into the cleanup:method of the PGMMainMenuViewController class:
- (void)cleanup
{
[self.peerGroupManager cleanup];
}
5.14 Registering modules
If your application would like to implement its own AllJoyn communication over the groups
established by the PeerGroupManager,then it must implement the PGMPeerGroupModule
protocol and register with the PeerGroupManager.
Note Registering a module is not normally necessary to use the PeerGroupManager.
It is available as an advanced feature in case an application needs to directly
access the bus attachment.A typical application,including the
PeerGroupManager sample app,does not need to register a module since it
has access to all the functionality it needs through the rest of the
PeerGroupManager API.
The following is an example of howa module might be registered in an advanced application.
First,define the module class to implement the PGMPeerGroupModule protocol:
@interface MyModule:PGMPeerGroupModule
@property (strong,nonatomic) AJNBusAttachment *bus;
@property (strong) AJNSessionId sessionId;
@end
@implementation MyModule
@synthesize bus = _bus;
@synthesize sessionId = _sessionId;
- (QStatus)registerOnBus:(AJNBusAttachment *)bus withSessionId:
(AJNSessionId)sessionId
{
self.bus = bus;
self.sessionId = sessionId;
QualcommInnovation Center,Inc.38HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Sample Walkthrough
}
@end
Elsewhere in your app,after you have created your PeerGroupManager and set up a group,
you can then register your module:
...
self.peerGroupManager = [[PGMPeerGroupManager alloc]
initWithGroupPrefix:@"org.alljoyn.PeerGroupManagerApp"
withPeerGroupDelegate:self withBusObjects:nil];
[self.peerGroupManager createGroupWithName:@”main”];
self.module = [[PGMPeerGroupModule] alloc] init];
[self.peerGroupManager registerModule:module forGroup:@”main”];
...
QualcommInnovation Center,Inc.39HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Sample Walkthrough
6 Diagrams
6.1 General flow
Figure 1 shows the general flow of execution while using the PeerGroupManager in a
typical application.
Figure 1:Peer Group Manager general flow
6.2 Advertisements
Figure 2 shows how advertisements for groups are constructed.
QualcommInnovation Center,Inc.40HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Figure 2:Construction of an Advertisement
QualcommInnovation Center,Inc.41HT80-BA069-1 Rev.A
MAY CONTAIN U.S.AND INTERNATIONAL EXPORT CONTROLLED INFORMATION
Peer Group Manager Usage Guide for iOS Diagrams