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 10.3 Rio | Samples and then navigate to either of the following folders:
- CPP/RTL/Tethering/BDShoppingList
- Object Pascal/RTL/Tethering/BDShoppingList
- Subversion Repository:
- You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
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 Projects Window, 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:
CreateShoppingListiteratesCDSProducts, builds a string list with the information fromCDSProductsthat 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:
ActionList1defines a single action,actGetList, which callsactGetListExecutewhen executed.TetherBDTest.Passwordis "TetherBDTest".TetherBDTestProfile:Actionscontains a local action that is associated withactGetListand is shared with remote profiles.Groupis "TetherBDTestGroup".ManagerisTetherBDTest.OnResourceReceivedis handled byTetherBDTestProfileResourceReceived.Resourcescontains a single local resource,ResShoppingList, which is shared with remote profiles.
CDSProducts:AfterPostis handled byCDSProductsAfterPost.- Handlers of
Form2’sOnCreateandOnCloseevents load and save theCDSProductsdata to a file, respectively.
Client Application
- The application defines the following methods:
CheckRemoteProfilesupdatesLabel2.Textwith the list of connected remote profiles and runs theactGetListremote action if required.
- The application defines the following event handlers:
TetherBDTestProfileResources0ResourceReceivedclears the list and adds new items toListView1with the updated data received on theResShoppingListmirror resource.tmCheckConnectionTimercallsCheckRemoteProfiles.TetherBDTestManagerEndAutoConnectcallsCheckRemoteProfiles.TetherBDTestManagerRemoteManagerShutdowncallsCheckRemoteProfiles.CommandManagerRequestManagerPasswordprovides the password of the remote server application: "TetherBDTest".
- The application defines the following controls:
Button1(Connect) startstmCheckConnectionand callsAutoConnectonTetherBDTestManager.- 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:OnEndAutoConnectis handled byTetherBDTestManagerEndAutoConnect.OnRemoteManagerShutdownis handled byTetherBDTestManagerRemoteManagerShutdown.OnRequestManagerPasswordis handled byTetherBDTestManagerRequestManagerPassword.
TetherBDTestProfile:- Actions contains a single local action with
Mirroras Kind and the same name as the action shared by the server application. This action is associated with the action inActionList1,actGetList. Groupis "TetherBDTestGroup".Resourcescontains a single local resource,ResShoppingList, withMirroras Kind and the same names as the resource shared by the server application. TheOnResourceReceivedevent of this local resource is handled byTetherBDTestProfileResources0ResourceReceived.
- Actions contains a single local action with
tmCheckConnectiontriggerstmCheckConnectionTimereach 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