Server Code for an Internet Access Control Application
In the preceding article we dealt with the functional requirements of the server application as well as with the components that make up the server interface. In this article we will continue to build on the concepts that we discussed there and at the same time explore the code that runs the server application.
Server Code for an Internet Access Control Application - Custom Procedures and Functions (Page 2 of 4 )
There are a few custom procedures and functions that I've created to facilitate the processing of communication and updating of the user interface. These are very important for the entire application and warrant a discussion. The first procedure is called "broadcastall" and is the medium that the program uses to communicate with all the workstations simultaneously:
The procedure defines a couple of variables, one of which is called Context. This variable inherits all of the properties of the TMyContext class and is extensively used throughout the procedure. The other variable that I want to draw your attention to is the "list" variable that is of type TList. This variable is used to inherit all the information that is contained in the TidContext class list:
List := form1.ts.Contexts.LockList;
The TidContext class contains a list of connected clients which is automatically generated and updated when a client connects or disconnects. The procedure starts by transferring the contents of the context object to the declared TList variable and locks the list, so that no new clients can be added while the procedure is busy broadcasting:
List := form1.ts.Contexts.LockList;
Then it counts the number of clients on the list and sets up a loop:
try
for I := 0 to List.Count-1 do
begin
Context := TMyContext(List[I]);
The procedure then writes to each client on the list. The communication sends a command called shutdown as shown below: