RTL.BDShoppingList Sample
BDShoppingList is a sample application with a client-server architecture where the server application keeps a table of products with the current and required units in stock, and a client application lets you increase the current units in stock remotely in batches of 100 units until you reach the required stock of a product.
Contents
Location
You can find the BDShoppingList project at:
- Start | Programs | Embarcadero RAD Studio Berlin | Samples and then navigate to either of the following folders:
- CPP/RTL/Tethering/BDShoppingList
- Object Pascal/RTL/Tethering/BDShoppingList
- Subversion Repository:
Description
This sample applications folder provides a client project and a server project. The projects are designed so that you can run any number of instances of the client project, but only one server.
In the server application (TetherDatabase) you have a grid with a table of products, and fields on top of the grid that you can use to edit records from the grid.
In the client application (TetherDBClient) you have a list of products without enough units in stock. There is also a Connect button that you can use to connect to the server. When you connect to the server, a label shows the name of the connected server.
How to Use the Sample
- Navigate to the location given above and open TetherShopping.groupproj.
- On the Project Manager, double-click TetherDatabase to activate the server application.
- Select Run > Run to run the server application.
- On the Project Manager, double-click TetherDBClient to activate the client application.
- Select Run > Run to run the client application.
Files
Each application in the project group contains a single source file that contains the class for the main form of the application.
Classes
Each application defines a single class that implements the main form of the application.
Implementation
Server Application
- The application defines the following methods:
CreateShoppingList
iteratesCDSProducts
, builds a string list with the information fromCDSProducts
that clients need, and saves the information as the value ofResShoppingList
.
- The application defines the following event handlers:
- The application defines several controls (input fields and a grid) that provide read and write access to the data in
CDSProducts
. - The application defines the following nonvisual components:
ActionList1
defines a single action,actGetList
, which callsactGetListExecute
when executed.TetherBDTest.Password
is "TetherBDTest".TetherBDTestProfile
:Actions
contains a local action that is associated withactGetList
and is shared with remote profiles.Group
is "TetherBDTestGroup".Manager
isTetherBDTest
.OnResourceReceived
is handled byTetherBDTestProfileResourceReceived
.Resources
contains a single local resource,ResShoppingList
, which is shared with remote profiles.
CDSProducts
:AfterPost
is handled byCDSProductsAfterPost
.- Handlers of
Form2
’sOnCreate
andOnClose
events load and save theCDSProducts
data to a file, respectively.
Client Application
- The application defines the following methods:
CheckRemoteProfiles
updatesLabel2.Text
with the list of connected remote profiles and runs theactGetList
remote action if required.
- The application defines the following event handlers:
TetherBDTestProfileResources0ResourceReceived
clears the list and adds new items toListView1
with the updated data received on theResShoppingList
mirror resource.tmCheckConnectionTimer
callsCheckRemoteProfiles
.TetherBDTestManagerEndAutoConnect
callsCheckRemoteProfiles
.TetherBDTestManagerRemoteManagerShutdown
callsCheckRemoteProfiles
.CommandManagerRequestManagerPassword
provides the password of the remote server application: "TetherBDTest".
- The application defines the following controls:
Button1
(Connect) startstmCheckConnection
and callsAutoConnect
onTetherBDTestManager
.- When you click a Buy 100 button in
ListView1
, the list sends the product ID of the list item to the server application.
- The application defines the following nonvisual components:
TetherBDTestManager
:OnEndAutoConnect
is handled byTetherBDTestManagerEndAutoConnect
.OnRemoteManagerShutdown
is handled byTetherBDTestManagerRemoteManagerShutdown
.OnRequestManagerPassword
is handled byTetherBDTestManagerRequestManagerPassword
.
TetherBDTestProfile
:- Actions contains a single local action with
Mirror
as Kind and the same name as the action shared by the server application. This action is associated with the action inActionList1
,actGetList
. Group
is "TetherBDTestGroup".Resources
contains a single local resource,ResShoppingList
, withMirror
as Kind and the same names as the resource shared by the server application. TheOnResourceReceived
event of this local resource is handled byTetherBDTestProfileResources0ResourceReceived
.
- Actions contains a single local action with
tmCheckConnection
triggerstmCheckConnectionTimer
each two seconds.
Uses
- System.Tether.AppProfile.TLocalResource
- System.Tether.AppProfile.TLocalResource.Kind
- System.Tether.AppProfile.TLocalResource.OnResourceReceived
- System.Tether.AppProfile.TLocalResource.Value
- System.Tether.AppProfile.TTetheringAppProfile
- System.Tether.AppProfile.TTetheringAppProfile.Actions
- System.Tether.AppProfile.TTetheringAppProfile.Group
- System.Tether.AppProfile.TTetheringAppProfile.Manager
- System.Tether.AppProfile.TTetheringAppProfile.OnResourceReceived
- System.Tether.AppProfile.TTetheringAppProfile.Resources
- System.Tether.AppProfile.TTetheringAppProfile.SendString
- System.Tether.Manager.TTetheringManager
- System.Tether.Manager.TTetheringManager.AutoConnect
- System.Tether.Manager.TTetheringManager.OnEndAutoConnect
- System.Tether.Manager.TTetheringManager.OnRemoteManagerShutdown
- System.Tether.Manager.TTetheringManager.OnRequestManagerPassword
- System.Tether.Manager.TTetheringManager.Password
- System.Tether.Manager.TTetheringManager.RemoteProfiles
See Also
- System.Tether unit
- DesktopCast sample
- MediaPlayer sample
- PhotoWall sample