Connecting to Remote Applications Using App Tethering
Go Up to Using App Tethering
Before the TTetheringAppProfile components of two applications can share actions and data using app tethering, your applications must discover and get paired with each other using their TTetheringManager component, and then their TTetheringAppProfile components must connect.
Requirements of Adapters and Protocols
To check the requirements of the built-in adapters and protocols, see:
- TTetheringNetworkAdapter, for local area network (LAN) connections.
- TTetheringTCPProtocol, for local area network (LAN) data transfers.
Choosing an Approach for Discovering, Pairing, and Connecting to Remote Applications
You can use either of the following approaches to discover and pair applications:
- Define two applications as belonging to the same group and use automatic discovering and pairing.
- Obtain a list of discovered applications and then request to pair with specific applications.
Using groups is simpler, but the manual approach offers more flexibility, and both approaches support password-protected pairing. Choose the approach that better fits your use case; you can also combine both approaches using the same TTetheringManager.
Using Groups to Connect Applications
If you want your applications to automatically discover and pair with each other:
- Enter the same string in the Group property of the TTetheringAppProfile component of each application.
- Call the AutoConnect method of the TTetheringManager component of each application at run time.
Choose a Group string that is as unique as possible, to prevent your applications from accidentally connecting to third-party applications that happen to use the same Group. For example, you can use a UUID as the Group string.
- Note: Third-party applications could still find out your Group and use it intentionally to connect automatically to your applications. If you don't want to allow third-party applications to automatically connect to your applications using app tethering, use a password.
When you call AutoConnect on one of your applications, your application discovers any other application that is also using app tethering, and your application automatically pairs and connects to those discovered applications that contain a TTetheringAppProfile component that is in the same Group as your TTetheringAppProfile component. When AutoConnect finishes, the OnEndAutoConnect event occurs.
Connecting with Remote Applications Manually
If you want to have more control over the discovering and pairing phases of the app tethering connection, you can use the following approach instead:
- Call the DiscoverManagers method of your TTetheringManager component of your application to start discovering other applications that use app tethering. When the discovery finishes, the OnEndManagersDiscovery event of your manager occurs.
- Read the list of discovered RemoteManagers of your TTetheringManager, and call TTetheringManager.PairManager to pair with those that you want. Each time that you pair your manager with a remote manager, the OnEndProfilesDiscovery event of your manager occurs.
- Read the list of discovered RemoteProfiles of your TTetheringManager, and call Connect on your TTetheringAppProfile component to connect to those that you want.
Remote managers and remote profiles are instances of TTetheringManagerInfo and TTetheringProfileInfo, respectively. These classes provide information about an instance of TTetheringManager or TTetheringAppProfile from a remote application. Use this information to determine whether or not to pair or connect with a specific remote manager or profile.
Using a Password for Pairing
The RTL provides password-based security for app tethering pairing between applications. You can use this password-based system to implement your own security procedure. For example, you can:
- Make your applications connect automatically when they discover each other, transparently to your users.
- Let your users manually enter a password in both applications to pair them.
Use the Password property of your manager to specify a password that remote managers must know in order to pair with your manager. When a manager attempts to pair with a password-protected remote manager, the OnRequestManagerPassword event of the local manager occurs, and the local manager must specify the correct password in this event. Otherwise, the pairing fails.
- Adding App Tethering to Your Application
- Sharing and Running Actions on Remote Applications Using App Tethering
- Sharing Data with Remote Applications Using App Tethering